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(
4848 if let Some ( pos) = tags. iter ( ) . rev ( ) . position ( |( t, _) | * t == tag_name) {
4949 // Because this is from a `rev` iterator, the position is reversed as well!
5050 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" ) ;
5154 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) {
5356 continue ;
5457 }
5558 // `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() {}
3939/// <h3>
4040//~^ ERROR unclosed HTML tag `h3`
4141pub 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