@@ -500,6 +500,73 @@ QUnit.test( "html(String) tag-hyphenated elements (Bug #1987)", function( assert
500500 assert . equal ( j . children ( ) . text ( ) , "text" , "Tags with multiple hypens behave normally" ) ;
501501} ) ;
502502
503+ QUnit . test ( "Tag name processing respects the HTML Standard (gh-2005)" , function ( assert ) {
504+
505+ assert . expect ( 240 ) ;
506+
507+ var wrapper = jQuery ( "<div></div>" ) ,
508+ nameTerminatingChars = "\x20\t\r\n\f" . split ( "" ) ,
509+ specialChars = "[ ] { } _ - = + \\ ( ) * & ^ % $ # @ ! ~ ` ' ; ? ¥ « µ λ ⊕ ≈ ξ ℜ ♣ €"
510+ . split ( " " ) ;
511+
512+ specialChars . push ( specialChars . join ( "" ) ) ;
513+
514+ jQuery . each ( specialChars , function ( i , characters ) {
515+ assertSpecialCharsSupport ( "html" , characters ) ;
516+ assertSpecialCharsSupport ( "append" , characters ) ;
517+ } ) ;
518+
519+ jQuery . each ( nameTerminatingChars , function ( i , character ) {
520+ assertNameTerminatingCharsHandling ( "html" , character ) ;
521+ assertNameTerminatingCharsHandling ( "append" , character ) ;
522+ } ) ;
523+
524+ function buildChild ( method , html ) {
525+ wrapper [ method ] ( html ) ;
526+ return wrapper . children ( ) [ 0 ] ;
527+ }
528+
529+ function assertSpecialCharsSupport ( method , characters ) {
530+ var child ,
531+ codepoint = characters . charCodeAt ( 0 ) . toString ( 16 ) . toUpperCase ( ) ,
532+ description = characters . length === 1 ?
533+ "U+" + ( "000" + codepoint ) . slice ( - 4 ) + " " + characters :
534+ "all special characters" ,
535+ nodeName = "valid" + characters + "tagname" ;
536+
537+ child = buildChild ( method , "<" + nodeName + "></" + nodeName + ">" ) ;
538+ assert . equal ( child . nodeName . toUpperCase ( ) , nodeName . toUpperCase ( ) ,
539+ method + "(): Paired tag name includes " + description ) ;
540+
541+ child = buildChild ( method , "<" + nodeName + ">" ) ;
542+ assert . equal ( child . nodeName . toUpperCase ( ) , nodeName . toUpperCase ( ) ,
543+ method + "(): Unpaired tag name includes " + description ) ;
544+
545+ child = buildChild ( method , "<" + nodeName + "/>" ) ;
546+ assert . equal ( child . nodeName . toUpperCase ( ) , nodeName . toUpperCase ( ) ,
547+ method + "(): Self-closing tag name includes " + description ) ;
548+ }
549+
550+ function assertNameTerminatingCharsHandling ( method , character ) {
551+ var child ,
552+ codepoint = character . charCodeAt ( 0 ) . toString ( 16 ) . toUpperCase ( ) ,
553+ description = "U+" + ( "000" + codepoint ) . slice ( - 4 ) + " " + character ,
554+ nodeName = "div" + character + "this-will-be-discarded" ;
555+
556+ child = buildChild ( method , "<" + nodeName + "></" + nodeName + ">" ) ;
557+ assert . equal ( child . nodeName . toUpperCase ( ) , "DIV" ,
558+ method + "(): Paired tag name terminated by " + description ) ;
559+
560+ child = buildChild ( method , "<" + nodeName + ">" ) ;
561+ assert . equal ( child . nodeName . toUpperCase ( ) , "DIV" ,
562+ method + "(): Unpaired open tag name terminated by " + description ) ;
563+
564+ child = buildChild ( method , "<" + nodeName + "/>" ) ;
565+ assert . equal ( child . nodeName . toUpperCase ( ) , "DIV" ,
566+ method + "(): Self-closing tag name terminated by " + description ) ;
567+ }
568+ } ) ;
569+
503570QUnit . test ( "IE8 serialization bug" , function ( assert ) {
504571
505572 assert . expect ( 2 ) ;
0 commit comments