Skip to content

Commit 5d522f5

Browse files
LeonardoBragamarkelog
authored andcommitted
Manipulation: add support to tag-hyphenated elements
Ref #1987 Ref 85ffc6d
1 parent f19595c commit 5d522f5

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
@@ -34,8 +34,8 @@ var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|" +
3434
rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
3535
rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
3636
rleadingWhitespace = /^\s+/,
37-
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
38-
rtagName = /<([\w:]+)/,
37+
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,
38+
rtagName = /<([\w:-]+)/,
3939
rhtml = /<|&#?\w+;/,
4040
rnoInnerhtml = /<(?:script|style|link)/i,
4141
// checked="checked" or checked

test/unit/manipulation.js

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

530+
test( "html(String) tag-hyphenated elements (Bug #1987)", function() {
531+
532+
expect( 27 );
533+
534+
jQuery.each( "thead tbody tfoot colgroup caption tr th td".split(" "), function( i, name ) {
535+
var j = jQuery("<" + name + "-d></" + name + "-d><" + name + "-d></" + name + "-d>");
536+
ok( j[0], "Create a tag-hyphenated element" );
537+
ok( jQuery.nodeName(j[0], name.toUpperCase() + "-D"), "Hyphenated node name" );
538+
ok( jQuery.nodeName(j[1], name.toUpperCase() + "-D"), "Hyphenated node name" );
539+
});
540+
541+
var j = jQuery("<tr-multiple-hyphens><td-with-hyphen>text</td-with-hyphen></tr-multiple-hyphens>");
542+
ok( jQuery.nodeName(j[0], "TR-MULTIPLE-HYPHENS"), "Tags with multiple hypens" );
543+
ok( jQuery.nodeName(j.children()[0], "TD-WITH-HYPHEN"), "Tags with multiple hypens" );
544+
equal( j.children().text(), "text", "Tags with multple hypens behave normally" );
545+
});
546+
530547
test( "IE8 serialization bug", function() {
531548

532549
expect( 2 );

0 commit comments

Comments
 (0)