Bug Tracker

Ticket #1029 (closed bug: wontfix)

Opened 2 years ago

Last modified 1 year ago

$().html() serializes href attribute in IE

Reported by: brandon Assigned to: anonymous
Type: bug Priority: major
Milestone: 1.1.3 Component: core
Version: 1.1.2 Keywords:
Cc: Needs: Review

Description (last modified by brandon) (diff)

Take the following text (snippet): <a href="/?q=node/1" rel="bookmark" title="Permanent Link to windows">

Load into an existing DOM using the following (val.primarylinks contains the above text): $("#primarylinks").hide().html(val.primarylinks).show();

The text is changed to: <a href="http://www.mydomain.com/?q=node/1" rel="bookmark" title="Permanent Link to windows">

As you can see, the href is being changed into an absolute path. I attempted to debug the script in vs2005 and it appears that the text actually changes during the "clean" function at this line: div.innerHTML = wrap[1] + s + wrap[2];

I'm no expert but it seems the assignment to innerHTML does some processing??? Assigning to innerText does not alter the string.

Attachments

Change History

Changed 2 years ago by brandon

From Fil on Dev list:

I had a similar problem with an <a href="~fil/..."> being transformed into <a href="%7Efil/..."> with the .html() method under FF (consequences were that the cookies were not transmitted, so the "action" was not "authorised"). This did not happen with .clone(), but .clone() was crashing Safari.

So finally I resorted to: jQuery.fn.clone2 = jQuery.browser.safari ? jQuery.fn.html : jQuery.fn.clone;

(under jquery 1.1.1 release 2); see http://trac.rezo.net/trac/spip/changeset/8786/spip/dist/javascript/async_upload.js

Changed 1 year ago by brandon

  • need set to Review
  • status changed from new to closed
  • resolution set to wontfix
  • description changed from Take the following text (snippet): <a href="/?q=node/1" rel="bookmark" title="Permanent Link to windows"> Load into an existing DOM using the following (val.primarylinks contains the above text): $("#primarylinks").hide().html(val.primarylinks).show(); The text is changed to: <a href="http://www.mydomain.com/?q=node/1" rel="bookmark" title="Permanent Link to windows"> As you can see, the href is being changed into an absolute path. I attempted to debug the script in vs2005 and it appears that the text actually changes during the "clean" function at this line: div.innerHTML = wrap[1] + s + wrap[2]; I'm no expert but it seems the assignment to innerHTML does some processing??? Assigning to innerText does not alter the string. to Take the following text (snippet): <a href="/?q=node/1" rel="bookmark" title="Permanent Link to windows"> Load into an existing DOM using the following (val.primarylinks contains the above text): $("#primarylinks").hide().html(val.primarylinks).show(); The text is changed to: <a href="http://www.mydomain.com/?q=node/1" rel="bookmark" title="Permanent Link to windows"> As you can see, the href is being changed into an absolute path. I attempted to debug the script in vs2005 and it appears that the text actually changes during the "clean" function at this line: div.innerHTML = wrap[1] + s + wrap[2]; I'm no expert but it seems the assignment to innerHTML does some processing??? Assigning to innerText does not alter the string.

IE serializes href and src attributes when using innerHTML ... thats it.

Note: See TracTickets for help on using tickets.