File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -48,8 +48,11 @@ fn drop_tag(
48
48
if let Some ( pos) = tags. iter ( ) . rev ( ) . position ( |( t, _) | * t == tag_name) {
49
49
// Because this is from a `rev` iterator, the position is reversed as well!
50
50
let pos = tags. len ( ) - 1 - pos;
51
+ // If the tag is nested inside a "<script>", not warning should be emitted.
52
+ let should_not_warn =
53
+ tags. iter ( ) . take ( pos + 1 ) . any ( |( at, _) | at == "script" || at == "style" ) ;
51
54
for ( last_tag_name, last_tag_span) in tags. drain ( pos + 1 ..) {
52
- if ALLOWED_UNCLOSED . iter ( ) . any ( |& at| at == & last_tag_name) {
55
+ if should_not_warn || ALLOWED_UNCLOSED . iter ( ) . any ( |& at| at == & last_tag_name) {
53
56
continue ;
54
57
}
55
58
// `tags` is used as a queue, meaning that everything after `pos` is included inside it.
Original file line number Diff line number Diff line change @@ -39,3 +39,25 @@ pub fn b() {}
39
39
/// <h3>
40
40
//~^ ERROR unclosed HTML tag `h3`
41
41
pub fn c ( ) { }
42
+
43
+ // Unclosed tags shouldn't warn if they are nested inside a <script> elem.
44
+ /// <script>
45
+ /// <h3><div>
46
+ /// </script>
47
+ /// <script>
48
+ /// <div>
49
+ /// <p>
50
+ /// </div>
51
+ /// </script>
52
+ pub fn d ( ) { }
53
+
54
+ // Unclosed tags shouldn't warn if they are nested inside a <style> elem.
55
+ /// <style>
56
+ /// <h3><div>
57
+ /// </style>
58
+ /// <style>
59
+ /// <div>
60
+ /// <p>
61
+ /// </div>
62
+ /// </style>
63
+ pub fn e ( ) { }
You can’t perform that action at this time.
0 commit comments