Permalink
Browse files

Manipulation: add support to tag-hyphenated elements

Fixes #1987
Closes gh-1988
  • Loading branch information...
LeonardoBraga authored and markelog committed Jan 5, 2015
1 parent fb85cb6 commit 69dda5b56b8199f9f9df3f1761538ba0183f24e5
Showing with 19 additions and 2 deletions.
  1. +2 −2 src/manipulation.js
  2. +17 −0 test/unit/manipulation.js
View
@@ -16,8 +16,8 @@ define([
], function( jQuery, concat, push, access, rcheckableType, support, dataPriv, dataUser ) {
var
- 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
View
@@ -486,6 +486,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 );

0 comments on commit 69dda5b

Please sign in to comment.