File tree 2 files changed +17
-5
lines changed
2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,18 @@ var oldInit = jQuery.fn.init,
10
10
// Make sure we trim BOM and NBSP
11
11
rtrim = / ^ [ \s \uFEFF \xA0 ] + | [ \s \uFEFF \xA0 ] + $ / g;
12
12
13
+ var makeMarkup = function ( html ) {
14
+ var createDoc = window . document . implementation . createHTMLDocument ;
15
+ if ( ! createDoc ) {
16
+ return ;
17
+ }
18
+ var doc = window . document . implementation . createHTMLDocument ( "" , "" , null ) ;
19
+ doc . open ( "replace" ) ;
20
+ doc . write ( html ) ;
21
+ doc . close ( ) ;
22
+ return doc . body && doc . body . innerHTML ;
23
+ } ;
24
+
13
25
jQuery . fn . init = function ( arg1 ) {
14
26
var args = Array . prototype . slice . call ( arguments ) ,
15
27
changed ;
@@ -23,12 +35,12 @@ jQuery.fn.init = function( arg1 ) {
23
35
24
36
if ( typeof arg1 === "string" && arg1 . trim ( ) . charAt ( 0 ) === "<" ) {
25
37
if ( ! rsingleTag . test ( arg1 ) ) {
26
- changed = arg1 . replace ( rxhtmlTag , "<$1></$2>" ) ;
27
- if ( changed !== arg1 ) {
28
- migrateWarn ( "HTML tags must be properly nested and closed: " + arg1 ) ;
38
+ changed = arg1 . replace ( rxhtmlTag , "<$1></$2>" ) ;
39
+ if ( changed !== arg1 && makeMarkup ( arg1 ) !== makeMarkup ( changed ) ) {
40
+ migrateWarn ( "HTML tags must be properly nested and closed: " + arg1 ) ;
41
+ }
29
42
}
30
43
}
31
- }
32
44
33
45
return oldInit . apply ( this , args ) ;
34
46
} ;
Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ QUnit.test( "Improperly closed elements", function( assert ) {
74
74
jQuery ( "<div data-borked='y'><span/> <p/></div>" ) ;
75
75
} ) ;
76
76
77
- expectWarning ( assert , "Elements not self-closable" , 3 , function ( ) {
77
+ expectNoWarning ( assert , "Elements not self-closable but tolerable" , function ( ) {
78
78
jQuery ( "<div class=wonky />" ) ;
79
79
jQuery ( "<p style='width: 2%' />" ) ;
80
80
jQuery ( "<span aria-label='hello' />" ) ;
You can’t perform that action at this time.
0 commit comments