mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Fix #12920: remove addMandatoryAttributes. Close gh-1037.
This commit is contained in:
parent
22f58bd688
commit
bb570fc373
@ -32,44 +32,24 @@ var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figca
|
||||
wrapMap = {
|
||||
option: [ 1, "<select multiple='multiple'>", "</select>" ],
|
||||
legend: [ 1, "<fieldset>", "</fieldset>" ],
|
||||
area: [ 1, "<map>", "</map>" ],
|
||||
param: [ 1, "<object>", "</object>" ],
|
||||
thead: [ 1, "<table>", "</table>" ],
|
||||
tr: [ 2, "<table><tbody>", "</tbody></table>" ],
|
||||
td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
|
||||
col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
|
||||
area: [ 1, "<map>", "</map>" ],
|
||||
_default: [ 0, "", "" ]
|
||||
td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
|
||||
|
||||
// IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
|
||||
// unless wrapped in a div with non-breaking characters in front of it.
|
||||
_default: jQuery.support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X<div>", "" ]
|
||||
},
|
||||
safeFragment = createSafeFragment( document ),
|
||||
fragmentDiv = safeFragment.appendChild( document.createElement("div") ),
|
||||
addMandatoryAttributes = function( elem ) { return elem; };
|
||||
fragmentDiv = safeFragment.appendChild( document.createElement("div") );
|
||||
|
||||
wrapMap.optgroup = wrapMap.option;
|
||||
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
|
||||
wrapMap.th = wrapMap.td;
|
||||
|
||||
// IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
|
||||
// unless wrapped in a div with non-breaking characters in front of it.
|
||||
if ( !jQuery.support.htmlSerialize ) {
|
||||
wrapMap._default = [ 1, "X<div>", "" ];
|
||||
// Fixes #11280
|
||||
wrapMap.param = [ 1, "X<object>", "" ];
|
||||
// Fixes #11280. HTMLParam name attribute added to avoid IE6-8 parsing issue.
|
||||
addMandatoryAttributes = function( elem ) {
|
||||
// If it's a param
|
||||
return elem.replace(/<param([^>]*)>/gi, function( m, s1, offset ) {
|
||||
var name = s1.match( /name=["']([^"']*)["']/i );
|
||||
return name ?
|
||||
( name[1].length ?
|
||||
// It has a name attr with a value
|
||||
"<param" + s1 + ">" :
|
||||
// It has name attr without a value
|
||||
"<param" + s1.replace( name[0], "name='_" + offset + "'" ) + ">" ) :
|
||||
// No name attr
|
||||
"<param name='_" + offset + "' " + s1 + ">";
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
jQuery.fn.extend({
|
||||
text: function( value ) {
|
||||
return jQuery.access( this, function( value ) {
|
||||
@ -733,7 +713,7 @@ jQuery.extend({
|
||||
// Deserialize a standard representation
|
||||
tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase();
|
||||
wrap = wrapMap[ tag ] || wrapMap._default;
|
||||
tmp.innerHTML = wrap[1] + addMandatoryAttributes( elem.replace( rxhtmlTag, "<$1></$2>" ) ) + wrap[2];
|
||||
tmp.innerHTML = wrap[1] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[2];
|
||||
|
||||
// Descend through wrappers to the right content
|
||||
j = wrap[0];
|
||||
|
@ -451,35 +451,19 @@ test("append(Function)", function() {
|
||||
});
|
||||
|
||||
test("append(param) to object, see #11280", function() {
|
||||
expect(11);
|
||||
expect( 5 );
|
||||
|
||||
var objectElement = document.createElement("object"),
|
||||
$objectElement = jQuery( objectElement ),
|
||||
paramElement = jQuery("<param type='wmode' value='transparent'/>"),
|
||||
paramElement2 = jQuery("<param name='' type='wmode2' value='transparent2' />"),
|
||||
paramElement3 = jQuery("<param type='wmode' name='foo' >"),
|
||||
newObject = jQuery("<object><param type='foo' ><param name='' value='foo2'/><param type='baz' name='bar'></object>");
|
||||
var object = jQuery( document.createElement("object") ).appendTo( document.body );
|
||||
|
||||
equal( objectElement.childNodes.length, 0, "object did not have childNodes previously" );
|
||||
equal( object.children().length, 0, "object does not start with children" );
|
||||
|
||||
document.body.appendChild( objectElement );
|
||||
object.append( jQuery("<param type='wmode' name='foo'>") );
|
||||
equal( object.children().length, 1, "appended param" );
|
||||
equal( object.children().eq(0).attr("name"), "foo", "param has name=foo" );
|
||||
|
||||
$objectElement.append( paramElement );
|
||||
equal( $objectElement.children().length, 1, "param single insertion ok" );
|
||||
equal( jQuery(objectElement.childNodes[0]).attr("type"), "wmode", "param.eq(0) has type=wmode" );
|
||||
|
||||
$objectElement.html( paramElement2 );
|
||||
equal( $objectElement.children().length, 1, "param single insertion ok" );
|
||||
equal( jQuery(objectElement.childNodes[0]).attr("type"), "wmode2", "param.eq(0) has type=wmode2" );
|
||||
|
||||
$objectElement.html( paramElement3 );
|
||||
equal( $objectElement.children().length, 1, "param single insertion ok" );
|
||||
equal( jQuery(objectElement.childNodes[0]).attr("name"), "foo", "param.eq(0) has name=foo" );
|
||||
|
||||
equal( newObject.children().length, 3, "param wrapper multiple insertion ok" );
|
||||
equal( newObject.children().eq(0).attr("type"), "foo", "param.eq(0) has type=foo" );
|
||||
equal( newObject.children().eq(1).attr("value"), "foo2", "param.eq(1) has value=foo2" );
|
||||
equal( newObject.children().eq(2).attr("name"), "bar", "param.eq(2) has name=bar" );
|
||||
object = jQuery("<object><param type='baz' name='bar'></object>");
|
||||
equal( object.children().length, 1, "object created with child param" );
|
||||
equal( object.children().eq(0).attr("name"), "bar", "param has name=bar" );
|
||||
});
|
||||
|
||||
test("append(Function) with incoming value", function() {
|
||||
|
Loading…
Reference in New Issue
Block a user