Skip to content

Commit 69dda5b

Browse files
LeonardoBragamarkelog
authored andcommitted
Manipulation: add support to tag-hyphenated elements
Fixes #1987 Closes gh-1988
1 parent fb85cb6 commit 69dda5b

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/manipulation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ define([
1616
], function( jQuery, concat, push, access, rcheckableType, support, dataPriv, dataUser ) {
1717

1818
var
19-
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
20-
rtagName = /<([\w:]+)/,
19+
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,
20+
rtagName = /<([\w:-]+)/,
2121
rhtml = /<|&#?\w+;/,
2222
rnoInnerhtml = /<(?:script|style|link)/i,
2323
// checked="checked" or checked

test/unit/manipulation.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,23 @@ test( "html(String) with HTML5 (Bug #6485)", function() {
486486
equal( jQuery("#qunit-fixture").children().children().children().length, 1, "Make sure nested HTML5 elements can hold children." );
487487
});
488488

489+
test( "html(String) tag-hyphenated elements (Bug #1987)", function() {
490+
491+
expect( 27 );
492+
493+
jQuery.each( "thead tbody tfoot colgroup caption tr th td".split(" "), function( i, name ) {
494+
var j = jQuery("<" + name + "-d></" + name + "-d><" + name + "-d></" + name + "-d>");
495+
ok( j[0], "Create a tag-hyphenated element" );
496+
ok( jQuery.nodeName(j[0], name.toUpperCase() + "-D"), "Hyphenated node name" );
497+
ok( jQuery.nodeName(j[1], name.toUpperCase() + "-D"), "Hyphenated node name" );
498+
});
499+
500+
var j = jQuery("<tr-multiple-hyphens><td-with-hyphen>text</td-with-hyphen></tr-multiple-hyphens>");
501+
ok( jQuery.nodeName(j[0], "TR-MULTIPLE-HYPHENS"), "Tags with multiple hypens" );
502+
ok( jQuery.nodeName(j.children()[0], "TD-WITH-HYPHEN"), "Tags with multiple hypens" );
503+
equal( j.children().text(), "text", "Tags with multple hypens behave normally" );
504+
});
505+
489506
test( "IE8 serialization bug", function() {
490507

491508
expect( 2 );

0 commit comments

Comments
 (0)