Bug Tracker

Opened 7 years ago

Closed 7 years ago

Last modified 7 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 7 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://jquery.com/upgrade-guide/1.9/#jquery-htmlstring-versus-jquery-selectorstring

Last edited 7 years ago by dmethvin (previous) (diff)

comment:2 Changed 7 years ago by dmethvin

Resolution: notabug
Status: newclosed

comment:3 Changed 7 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.