Side navigation
#4617 closed feature (duplicate)
Opened May 02, 2009 07:14PM UTC
Closed November 21, 2010 02:11AM UTC
Last modified March 13, 2012 03:46PM UTC
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"), "");
}
Attachments (0)
Change History (5)
Changed June 13, 2010 02:39AM UTC by comment:1
component: | unfiled → core |
---|
Changed November 11, 2010 02:35PM UTC by comment:3
milestone: | 1.4 → 1.5 |
---|---|
priority: | major → low |
status: | new → open |
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.
Changed November 21, 2010 02:11AM UTC by comment:4
resolution: | → duplicate |
---|---|
status: | open → closed |