Bug Tracker

Modify

Ticket #1753 (closed feature: duplicate)

Opened 6 years ago

Last modified 3 years ago

inconsistent processing for xml vs html

Reported by: jacktanner Owned by:
Priority: major Milestone: 1.2.2
Component: core Version: 1.2.1
Keywords: Cc:
Blocking: Blocked by:

Description

In jQuery 1.2.1, line 783 does this:

div = doc.createElement("div")

The attributes that Firefox 2.0.0.7 creates for div are different depending on whether a page is loaded as foo.html or foo.xml. In particular, when the file is XML, there's no div.innerHTML, only div.textContent. This causes a problem down on line 813:

div.innerHTML = wrap[1] + arg + wrap[2];

When the file is HTML, that statement assigns a value to both div.innerHTML and div.textContent. When the file is XML, that statement creates div.innerHTML and assigns its value, but does not affect div.textContent.

A workaround is to do this:

div.innerHTML = wrap[1] + arg + wrap[2]; div.textContent = arg;

I'm not sure if this is a true workaround, because it fails if arg contains any HTML tags.

See  http://pastie.caboo.se/101771. Save this code as foo.html and as foo.xml.

Change History

comment:1 Changed 5 years ago by davidserduke

  • Type changed from bug to feature

At this point jQuery doesn't support text parsing to xml. While it seems to sort of works in some browsers, really that is just non-standard html (which works in FF for example). While xml support for text parsing like:

$("<root><child>text</child><child/></root>");

may be added to the core at some point, for now it will work inconsistently at best. I'm going to change this to a feature request from a bug.

Related tickets #1850, #1991.

comment:2 Changed 3 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to duplicate

I'm grouping these under #6693 as a feature request.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.