Bug Tracker

Opened 14 years ago

Closed 12 years ago

Last modified 11 years ago

#4617 closed feature (duplicate)

xml() function, or addition to html() function

Reported by: yuniti Owned by:
Priority: low Milestone: 1.5
Component: core Version: 1.3.2
Keywords: xml, innerXml Cc:
Blocked by: Blocking:

Description

Not sure what the preference would be - the advantage of making an xml() function would be that it is more sensical and would not allow a parameter, whereas html() would be consistent. In any case, below are both functions. xml() has been tested, html() was simply modified using the xml() code.

html: function( value ) {

var node = this[0]; return value === undefined ?

(node ?

(node.innerHTML ?

node.innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g, "") :

(node.xml
(new XMLSerializer()).serializeToString(node) "")

.replace(new RegExp("(<
w*" + node.tagName + "[
>]*>)|(<
w*
/
w*" + node.tagName + "[>]*>$)", "gi"), "")) :

null) :

this.empty().append( value );

},

xml : function()

{

var node = this[0],

tagName = node.tagName;

if ( ! tagName )

return this.html();

return (node.xml
(new XMLSerializer()).serializeToString(node) "").replace(

new RegExp("(<
w*" + tagName + "[
>]*>)|(<
w*
/
w*" + tagName + "[>]*>$)", "gi"), "");

}

Change History (5)

comment:1 Changed 13 years ago by dmethvin

Component: unfiledcore

comment:2 Changed 12 years ago by dmethvin

#5022 is a duplicate of this ticket.

comment:3 Changed 12 years ago by SlexAxton

Milestone: 1.41.5
Priority: majorlow
Status: newopen

Jakibo had some good notes on this one on the dupe ticket:

https://github.com/jablko/jquery/commit/2fea569dce44e5f6df8d67fef277db4599d4aab2 http://groups.google.com/group/jquery-dev/browse_thread/thread/594106bdd4dc7375?pli=1 http://www.sfu.ca/~jdbates/tmp/jquery/201004090/patch

Dmethvin asked for a less magical approach though, so merging up minds for this one could help.

comment:4 Changed 12 years ago by dmethvin

Resolution: duplicate
Status: openclosed

comment:5 Changed 12 years ago by dmethvin

Duplicate of #6693.

Note: See TracTickets for help on using tickets.