// Set the existing or create a new attribute node
var ret = elem.getAttributeNode( name );
if ( !ret ) {
- ret = document.createAttribute( name );
+ ret = elem.ownerDocument.createAttribute( name );
elem.setAttributeNode( ret );
}
return ( ret.value = value + "" );
"testIframe": true,
"testIframeWithCallback": true,
"createDashboardXML": true,
+ "createXMLFragment": true,
"moduleTeardown": true,
"testFoo": true,
"foobar": true,
return jQuery.parseXML(string);
};
+var createXMLFragment = function() {
+ var xml, frag;
+ if ( window.ActiveXObject ) {
+ xml = new ActiveXObject("msxml2.domdocument");
+ } else {
+ xml = document.implementation.createDocument( "", "", null );
+ }
+
+ if ( xml ) {
+ frag = xml.createElement("data");
+ }
+
+ return frag;
+};
+
var fireNative;
if ( document.createEvent ) {
fireNative = function( node, type ) {
equal( titles[ 1 ], "Users", "attr() in XML context: Check second title" );
});
+test( "attr(String, Object) - Loaded via XML fragment", function() {
+ expect( 2 );
+ var frag = createXMLFragment(),
+ $frag = jQuery( frag );
+
+ $frag.attr( "test", "some value" );
+ equal( $frag.attr("test"), "some value", "set attribute" );
+ $frag.attr( "test", null );
+ equal( $frag.attr("test"), undefined, "remove attribute" );
+});
+
test( "attr('tabindex')", function() {
expect( 8 );