@@ -37,6 +37,8 @@ const startTagOpen = new RegExp('^<' + qnameCapture)
3737const startTagClose = / ^ \s * ( \/ ? ) > /
3838const endTag = new RegExp ( '^<\\/' + qnameCapture + '[^>]*>' )
3939const doctype = / ^ < ! D O C T Y P E [ ^ > ] + > / i
40+ const comment = / ^ < ! - - /
41+ const conditionalComment = / ^ < ! \[ /
4042
4143let IS_REGEX_CAPTURING_BROKEN = false
4244'x' . replace ( / x ( .) ? / g, function ( m , g ) {
@@ -94,7 +96,7 @@ export function parseHTML (html, options) {
9496 let textEnd = html . indexOf ( '<' )
9597 if ( textEnd === 0 ) {
9698 // Comment:
97- if ( / ^ < ! - - / . test ( html ) ) {
99+ if ( comment . test ( html ) ) {
98100 const commentEnd = html . indexOf ( '-->' )
99101
100102 if ( commentEnd >= 0 ) {
@@ -104,7 +106,7 @@ export function parseHTML (html, options) {
104106 }
105107
106108 // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
107- if ( / ^ < ! \[ / . test ( html ) ) {
109+ if ( conditionalComment . test ( html ) ) {
108110 const conditionalEnd = html . indexOf ( ']>' )
109111
110112 if ( conditionalEnd >= 0 ) {
@@ -140,7 +142,12 @@ export function parseHTML (html, options) {
140142 let text , rest
141143 if ( textEnd > 0 ) {
142144 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+ ) {
144151 // < in plain text, be forgiving and treat it as text
145152 textEnd += rest . indexOf ( '<' , 1 )
146153 rest = html . slice ( textEnd )
0 commit comments