Skip to content

Commit f19595c

Browse files
LeonardoBragamarkelog
authored andcommitted
Core: add support to tag-hyphenated elements
Ref #1987 Ref 534f130
1 parent abfb10c commit f19595c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/core/var/rsingleTag.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
define(function() {
22
// Match a standalone tag
3-
return (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
3+
return (/^<([\w-]+)\s*\/?>(?:<\/\1>|)$/);
44
});

test/unit/core.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,19 @@ test("jQuery('html')", function() {
599599
equal( jQuery( "\\<div\\>" ).length, 0, "Ignore escaped html characters" );
600600
});
601601

602+
test("jQuery(tag-hyphenated elements) gh-1987", function() {
603+
expect( 17 );
604+
605+
jQuery.each( "thead tbody tfoot colgroup caption tr th td".split(" "), function( i, name ) {
606+
var j = jQuery("<" + name + "-d></" + name + "-d>");
607+
ok( j[0], "Create a tag-hyphenated elements" );
608+
ok( jQuery.nodeName(j[0], name.toUpperCase() + "-D"), "Tag-hyphenated element has expected node name" );
609+
});
610+
611+
var j = jQuery("<tr-multiple-hyphens></tr-multiple-hyphens>");
612+
ok( jQuery.nodeName(j[0], "TR-MULTIPLE-HYPHENS"), "Element with multiple hyphens in its tag has expected node name" );
613+
});
614+
602615
test("jQuery('massive html #7990')", function() {
603616
expect( 3 );
604617

0 commit comments

Comments
 (0)