Skip to main content

Bug Tracker

Side navigation

#9843 closed bug (worksforme)

Opened July 16, 2011 12:53PM UTC

Closed July 16, 2011 03:23PM UTC

Last modified July 16, 2011 03:51PM UTC

html() method can't handle HTML encoded characters [ampersand-style]

Reported by: shehriyari Owned by:
Priority: low Milestone: 1.next
Component: manipulation Version: 1.6.2
Keywords: Cc:
Blocked by: Blocking:
Description

HOW TO REPEAT:

Let's say we have following piece of code:

var someVar = "<b>"Don&39;t!"</b>;

jQuery("#someDiv").html(someVar);

EXPECTED BEHAVIOUR:

#someDiv gets following content: <b>"Don&39;t!"</b>

WHAT HAPPENS:

Instead #someDiv gets following content: <b>"Don&39;t!"</b>

As you can see, html() method handles ampersand-and-numbers-encoded-special-characters the way text() method does/should. **"** character is rendered correctly, but **&39;** is not!

Attachments (0)
Change History (4)

Changed July 16, 2011 01:03PM UTC by shehriyari comment:1

Sample code @JsFiddle:

http://jsfiddle.net/GRwP7/

Changed July 16, 2011 03:23PM UTC by rwaldron comment:2

component: unfiledmanipulation
priority: undecidedlow
resolution: → worksforme
status: newclosed

Changed July 16, 2011 03:43PM UTC by timmywil comment:3

rwaldron beat me to it. That character code is invalid btw.

http://jsfiddle.net/timmywil/GRwP7/3/

Changed July 16, 2011 03:51PM UTC by shehriyari comment:4

@rwaldron: Point was numeric-encodings, not alpha ones. Your fix was irrelevant sorry.

@timmywil: He didn't actually. Thanks for pointing out my error. Apparently I missed the hash (#) sign.