Bug Tracker

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#13224 closed bug (notabug)

problem with backslashed multiline string

Reported by: anonymous Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.9.0
Keywords: Cc:
Blocked by: Blocking:

Description

Creating element or sub-tree from a string, that writed in a few lines with backslashes at the line ends now gives a syntax error.

jQuery('\

<div></div>\

'); => Error: Syntax error, unrecognized expression: <div></div>

but

jQuery('<div></div>'); => [<div>​</div>​]

Change History (3)

comment:1 Changed 10 years ago by dmethvin

Use $.parseHTML() for those cases, it is much more lenient about what it parses and also lets you specify whether to process script tags. See the upgrade guide for an example, if you haven't read it already.

http://stage.jquery.com/upgrade-guide/1.9/#jquery-htmlstring-versus-jquery-selectorstring

Version 0, edited 10 years ago by dmethvin (next)

comment:2 Changed 10 years ago by dmethvin

Resolution: notabug
Status: newclosed

comment:3 Changed 10 years ago by dmethvin

Oh also, if you just want to have a literal string with newlines, try

jQuery($.trim('\

<div></div>\

'));
Note: See TracTickets for help on using tickets.