@@ -37,6 +37,8 @@ const startTagOpen = new RegExp('^<' + qnameCapture)
37
37
const startTagClose = / ^ \s * ( \/ ? ) > /
38
38
const endTag = new RegExp ( '^<\\/' + qnameCapture + '[^>]*>' )
39
39
const doctype = / ^ < ! D O C T Y P E [ ^ > ] + > / i
40
+ const comment = / ^ < ! - - /
41
+ const conditionalComment = / ^ < ! \[ /
40
42
41
43
let IS_REGEX_CAPTURING_BROKEN = false
42
44
'x' . replace ( / x ( .) ? / g, function ( m , g ) {
@@ -94,7 +96,7 @@ export function parseHTML (html, options) {
94
96
let textEnd = html . indexOf ( '<' )
95
97
if ( textEnd === 0 ) {
96
98
// Comment:
97
- if ( / ^ < ! - - / . test ( html ) ) {
99
+ if ( comment . test ( html ) ) {
98
100
const commentEnd = html . indexOf ( '-->' )
99
101
100
102
if ( commentEnd >= 0 ) {
@@ -104,7 +106,7 @@ export function parseHTML (html, options) {
104
106
}
105
107
106
108
// http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
107
- if ( / ^ < ! \[ / . test ( html ) ) {
109
+ if ( conditionalComment . test ( html ) ) {
108
110
const conditionalEnd = html . indexOf ( ']>' )
109
111
110
112
if ( conditionalEnd >= 0 ) {
@@ -140,7 +142,12 @@ export function parseHTML (html, options) {
140
142
let text , rest
141
143
if ( textEnd > 0 ) {
142
144
rest = html . slice ( textEnd )
143
- while ( ! startTagOpen . test ( rest ) && ! endTag . test ( rest ) ) {
145
+ while (
146
+ ! endTag . test ( rest ) &&
147
+ ! startTagOpen . test ( rest ) &&
148
+ ! comment . test ( rest ) &&
149
+ ! conditionalComment . test ( rest )
150
+ ) {
144
151
// < in plain text, be forgiving and treat it as text
145
152
textEnd += rest . indexOf ( '<' , 1 )
146
153
rest = html . slice ( textEnd )
0 commit comments