]> source.dussan.org Git - jquery.git/commitdiff
Manipulation: add support to tag-hyphenated elements
authorLeonardo Braga <leonardo.braga@gmail.com>
Tue, 13 Jan 2015 04:50:23 +0000 (07:50 +0300)
committerOleg Gaidarenko <markelog@gmail.com>
Tue, 13 Jan 2015 04:54:37 +0000 (07:54 +0300)
Ref #1987
Ref 85ffc6d973865a031ded170934e0acfc2e97cb11

src/manipulation.js
test/unit/manipulation.js

index c17aad831ef4acbcd738f4dd42dd555e7d905f83..aaa3827c6503bb0bd7d050e9e16f4c4c2051a114 100644 (file)
@@ -34,8 +34,8 @@ var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|" +
        rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
        rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
        rleadingWhitespace = /^\s+/,
-       rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
-       rtagName = /<([\w:]+)/,
+       rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,
+       rtagName = /<([\w:-]+)/,
        rhtml = /<|&#?\w+;/,
        rnoInnerhtml = /<(?:script|style|link)/i,
        // checked="checked" or checked
index 302d1948fff310d2499fc9e0d06bd77435693468..2f63f047c093ad94d30a19ca136bea0ec68a9fb0 100644 (file)
@@ -527,6 +527,23 @@ test( "html(String) with HTML5 (Bug #6485)", function() {
        equal( jQuery("#qunit-fixture").children().children().children().length, 1, "Make sure nested HTML5 elements can hold children." );
 });
 
+test( "html(String) tag-hyphenated elements (Bug #1987)", function() {
+
+       expect( 27 );
+
+       jQuery.each( "thead tbody tfoot colgroup caption tr th td".split(" "), function( i, name ) {
+               var j = jQuery("<" + name + "-d></" + name + "-d><" + name + "-d></" + name + "-d>");
+               ok( j[0], "Create a tag-hyphenated element" );
+               ok( jQuery.nodeName(j[0], name.toUpperCase() + "-D"), "Hyphenated node name" );
+               ok( jQuery.nodeName(j[1], name.toUpperCase() + "-D"), "Hyphenated node name" );
+       });
+
+       var j = jQuery("<tr-multiple-hyphens><td-with-hyphen>text</td-with-hyphen></tr-multiple-hyphens>");
+       ok( jQuery.nodeName(j[0], "TR-MULTIPLE-HYPHENS"), "Tags with multiple hypens" );
+       ok( jQuery.nodeName(j.children()[0], "TD-WITH-HYPHEN"), "Tags with multiple hypens" );
+       equal( j.children().text(), "text", "Tags with multple hypens behave normally" );
+});
+
 test( "IE8 serialization bug", function() {
 
        expect( 2 );