refactor: further tweak compiler layers

This commit is contained in:
Evan You 2019-09-17 11:57:25 -04:00
parent 6c14b409ca
commit 132cef9063
31 changed files with 288 additions and 269 deletions

View File

@ -2,9 +2,9 @@ module.exports = {
preset: 'ts-jest',
globals: {
__DEV__: true,
__BROWSER__: false,
__JSDOM__: true,
__FEATURE_OPTIONS__: true,
__FEATURE_PRODUCTION_TIP__: false,
__FEATURE_SUSPENSE__: true
},
coverageDirectory: 'coverage',

View File

@ -1,78 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`base parser invalid html 1`] = `
Object {
"children": Array [
Object {
"children": Array [
Object {
"children": Array [],
"isSelfClosing": false,
"loc": Object {
"end": Object {
"column": 1,
"line": 3,
"offset": 13,
},
"source": "<span>
",
"start": Object {
"column": 1,
"line": 2,
"offset": 6,
},
},
"ns": 0,
"props": Array [],
"tag": "span",
"tagType": 0,
"type": 2,
},
],
"isSelfClosing": false,
"loc": Object {
"end": Object {
"column": 7,
"line": 3,
"offset": 19,
},
"source": "<div>
<span>
</div>",
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"ns": 0,
"props": Array [],
"tag": "div",
"tagType": 0,
"type": 2,
},
],
"loc": Object {
"end": Object {
"column": 8,
"line": 4,
"offset": 27,
},
"source": "<div>
<span>
</div>
</span>",
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": 6,
}
`;
exports[`base parser onError option ABRUPT_CLOSING_OF_EMPTY_COMMENT <template><!--></template> 1`] = `
exports[`base parser Errors ABRUPT_CLOSING_OF_EMPTY_COMMENT <template><!--></template> 1`] = `
Object {
"children": Array [
Object {
@ -133,7 +61,7 @@ Object {
}
`;
exports[`base parser onError option ABRUPT_CLOSING_OF_EMPTY_COMMENT <template><!---></template> 1`] = `
exports[`base parser Errors ABRUPT_CLOSING_OF_EMPTY_COMMENT <template><!---></template> 1`] = `
Object {
"children": Array [
Object {
@ -194,7 +122,7 @@ Object {
}
`;
exports[`base parser onError option ABRUPT_CLOSING_OF_EMPTY_COMMENT <template><!----></template> 1`] = `
exports[`base parser Errors ABRUPT_CLOSING_OF_EMPTY_COMMENT <template><!----></template> 1`] = `
Object {
"children": Array [
Object {
@ -255,7 +183,7 @@ Object {
}
`;
exports[`base parser onError option ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE <template attr="&#99;"></template> 1`] = `
exports[`base parser Errors ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE <template attr="&#99;"></template> 1`] = `
Object {
"children": Array [
Object {
@ -334,7 +262,7 @@ Object {
}
`;
exports[`base parser onError option ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE <template attr="&#a;"></template> 1`] = `
exports[`base parser Errors ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE <template attr="&#a;"></template> 1`] = `
Object {
"children": Array [
Object {
@ -413,7 +341,7 @@ Object {
}
`;
exports[`base parser onError option ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE <template attr="&#xff;"></template> 1`] = `
exports[`base parser Errors ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE <template attr="&#xff;"></template> 1`] = `
Object {
"children": Array [
Object {
@ -492,7 +420,7 @@ Object {
}
`;
exports[`base parser onError option ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE <template attr="&#xg;"></template> 1`] = `
exports[`base parser Errors ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE <template attr="&#xg;"></template> 1`] = `
Object {
"children": Array [
Object {
@ -571,7 +499,7 @@ Object {
}
`;
exports[`base parser onError option ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE <template>&#99;</template> 1`] = `
exports[`base parser Errors ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE <template>&#99;</template> 1`] = `
Object {
"children": Array [
Object {
@ -633,7 +561,7 @@ Object {
}
`;
exports[`base parser onError option ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE <template>&#a;</template> 1`] = `
exports[`base parser Errors ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE <template>&#a;</template> 1`] = `
Object {
"children": Array [
Object {
@ -695,7 +623,7 @@ Object {
}
`;
exports[`base parser onError option ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE <template>&#xff;</template> 1`] = `
exports[`base parser Errors ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE <template>&#xff;</template> 1`] = `
Object {
"children": Array [
Object {
@ -757,7 +685,7 @@ Object {
}
`;
exports[`base parser onError option ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE <template>&#xg;</template> 1`] = `
exports[`base parser Errors ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE <template>&#xg;</template> 1`] = `
Object {
"children": Array [
Object {
@ -819,7 +747,7 @@ Object {
}
`;
exports[`base parser onError option CDATA_IN_HTML_CONTENT <template><![CDATA[cdata]]></template> 1`] = `
exports[`base parser Errors CDATA_IN_HTML_CONTENT <template><![CDATA[cdata]]></template> 1`] = `
Object {
"children": Array [
Object {
@ -880,7 +808,7 @@ Object {
}
`;
exports[`base parser onError option CDATA_IN_HTML_CONTENT <template><svg><![CDATA[cdata]]></svg></template> 1`] = `
exports[`base parser Errors CDATA_IN_HTML_CONTENT <template><svg><![CDATA[cdata]]></svg></template> 1`] = `
Object {
"children": Array [
Object {
@ -965,7 +893,7 @@ Object {
}
`;
exports[`base parser onError option CHARACTER_REFERENCE_OUTSIDE_UNICODE_RANGE <template>&#1234567;</template> 1`] = `
exports[`base parser Errors CHARACTER_REFERENCE_OUTSIDE_UNICODE_RANGE <template>&#1234567;</template> 1`] = `
Object {
"children": Array [
Object {
@ -1027,7 +955,7 @@ Object {
}
`;
exports[`base parser onError option CONTROL_CHARACTER_REFERENCE <template>&#0003;</template> 1`] = `
exports[`base parser Errors CONTROL_CHARACTER_REFERENCE <template>&#0003;</template> 1`] = `
Object {
"children": Array [
Object {
@ -1089,7 +1017,7 @@ Object {
}
`;
exports[`base parser onError option CONTROL_CHARACTER_REFERENCE <template>&#x7F;</template> 1`] = `
exports[`base parser Errors CONTROL_CHARACTER_REFERENCE <template>&#x7F;</template> 1`] = `
Object {
"children": Array [
Object {
@ -1151,7 +1079,7 @@ Object {
}
`;
exports[`base parser onError option DUPLICATE_ATTRIBUTE <template><div id="" id=""></div></template> 1`] = `
exports[`base parser Errors DUPLICATE_ATTRIBUTE <template><div id="" id=""></div></template> 1`] = `
Object {
"children": Array [
Object {
@ -1288,7 +1216,7 @@ Object {
}
`;
exports[`base parser onError option END_TAG_WITH_ATTRIBUTES <template><div></div id=""></template> 1`] = `
exports[`base parser Errors END_TAG_WITH_ATTRIBUTES <template><div></div id=""></template> 1`] = `
Object {
"children": Array [
Object {
@ -1354,7 +1282,7 @@ Object {
}
`;
exports[`base parser onError option END_TAG_WITH_TRAILING_SOLIDUS <template><div></div/></template> 1`] = `
exports[`base parser Errors END_TAG_WITH_TRAILING_SOLIDUS <template><div></div/></template> 1`] = `
Object {
"children": Array [
Object {
@ -1420,7 +1348,7 @@ Object {
}
`;
exports[`base parser onError option EOF_BEFORE_TAG_NAME <template>< 1`] = `
exports[`base parser Errors EOF_BEFORE_TAG_NAME <template>< 1`] = `
Object {
"children": Array [
Object {
@ -1482,7 +1410,7 @@ Object {
}
`;
exports[`base parser onError option EOF_BEFORE_TAG_NAME <template></ 1`] = `
exports[`base parser Errors EOF_BEFORE_TAG_NAME <template></ 1`] = `
Object {
"children": Array [
Object {
@ -1544,7 +1472,7 @@ Object {
}
`;
exports[`base parser onError option EOF_IN_CDATA <template><svg><![CDATA[ 1`] = `
exports[`base parser Errors EOF_IN_CDATA <template><svg><![CDATA[ 1`] = `
Object {
"children": Array [
Object {
@ -1610,7 +1538,7 @@ Object {
}
`;
exports[`base parser onError option EOF_IN_CDATA <template><svg><![CDATA[cdata 1`] = `
exports[`base parser Errors EOF_IN_CDATA <template><svg><![CDATA[cdata 1`] = `
Object {
"children": Array [
Object {
@ -1695,7 +1623,7 @@ Object {
}
`;
exports[`base parser onError option EOF_IN_COMMENT <template><! 1`] = `
exports[`base parser Errors EOF_IN_COMMENT <template><! 1`] = `
Object {
"children": Array [
Object {
@ -1756,7 +1684,7 @@ Object {
}
`;
exports[`base parser onError option EOF_IN_COMMENT <template><!- 1`] = `
exports[`base parser Errors EOF_IN_COMMENT <template><!- 1`] = `
Object {
"children": Array [
Object {
@ -1817,7 +1745,7 @@ Object {
}
`;
exports[`base parser onError option EOF_IN_COMMENT <template><!-- 1`] = `
exports[`base parser Errors EOF_IN_COMMENT <template><!-- 1`] = `
Object {
"children": Array [
Object {
@ -1878,7 +1806,7 @@ Object {
}
`;
exports[`base parser onError option EOF_IN_COMMENT <template><!--comment 1`] = `
exports[`base parser Errors EOF_IN_COMMENT <template><!--comment 1`] = `
Object {
"children": Array [
Object {
@ -1939,7 +1867,7 @@ Object {
}
`;
exports[`base parser onError option EOF_IN_COMMENT <template><!abc 1`] = `
exports[`base parser Errors EOF_IN_COMMENT <template><!abc 1`] = `
Object {
"children": Array [
Object {
@ -2000,7 +1928,7 @@ Object {
}
`;
exports[`base parser onError option EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT <script><!--console.log('hello') 1`] = `
exports[`base parser Errors EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT <script><!--console.log('hello') 1`] = `
Object {
"children": Array [
Object {
@ -2062,7 +1990,7 @@ Object {
}
`;
exports[`base parser onError option EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT <script>console.log('hello') 1`] = `
exports[`base parser Errors EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT <script>console.log('hello') 1`] = `
Object {
"children": Array [
Object {
@ -2124,7 +2052,7 @@ Object {
}
`;
exports[`base parser onError option EOF_IN_TAG <template><div 1`] = `
exports[`base parser Errors EOF_IN_TAG <template><div 1`] = `
Object {
"children": Array [
Object {
@ -2190,7 +2118,7 @@ Object {
}
`;
exports[`base parser onError option EOF_IN_TAG <template><div 1`] = `
exports[`base parser Errors EOF_IN_TAG <template><div 1`] = `
Object {
"children": Array [
Object {
@ -2256,7 +2184,7 @@ Object {
}
`;
exports[`base parser onError option EOF_IN_TAG <template><div id 1`] = `
exports[`base parser Errors EOF_IN_TAG <template><div id 1`] = `
Object {
"children": Array [
Object {
@ -2341,7 +2269,7 @@ Object {
}
`;
exports[`base parser onError option EOF_IN_TAG <template><div id = 1`] = `
exports[`base parser Errors EOF_IN_TAG <template><div id = 1`] = `
Object {
"children": Array [
Object {
@ -2426,7 +2354,7 @@ Object {
}
`;
exports[`base parser onError option EOF_IN_TAG <template><div id 1`] = `
exports[`base parser Errors EOF_IN_TAG <template><div id 1`] = `
Object {
"children": Array [
Object {
@ -2511,7 +2439,7 @@ Object {
}
`;
exports[`base parser onError option EOF_IN_TAG <template><div id="abc 1`] = `
exports[`base parser Errors EOF_IN_TAG <template><div id="abc 1`] = `
Object {
"children": Array [
Object {
@ -2613,7 +2541,7 @@ Object {
}
`;
exports[`base parser onError option EOF_IN_TAG <template><div id="abc" 1`] = `
exports[`base parser Errors EOF_IN_TAG <template><div id="abc" 1`] = `
Object {
"children": Array [
Object {
@ -2715,7 +2643,7 @@ Object {
}
`;
exports[`base parser onError option EOF_IN_TAG <template><div id="abc"/ 1`] = `
exports[`base parser Errors EOF_IN_TAG <template><div id="abc"/ 1`] = `
Object {
"children": Array [
Object {
@ -2817,7 +2745,7 @@ Object {
}
`;
exports[`base parser onError option EOF_IN_TAG <template><div id='abc 1`] = `
exports[`base parser Errors EOF_IN_TAG <template><div id='abc 1`] = `
Object {
"children": Array [
Object {
@ -2919,7 +2847,7 @@ Object {
}
`;
exports[`base parser onError option EOF_IN_TAG <template><div id='abc' 1`] = `
exports[`base parser Errors EOF_IN_TAG <template><div id='abc' 1`] = `
Object {
"children": Array [
Object {
@ -3021,7 +2949,7 @@ Object {
}
`;
exports[`base parser onError option EOF_IN_TAG <template><div id='abc'/ 1`] = `
exports[`base parser Errors EOF_IN_TAG <template><div id='abc'/ 1`] = `
Object {
"children": Array [
Object {
@ -3123,7 +3051,7 @@ Object {
}
`;
exports[`base parser onError option EOF_IN_TAG <template><div id=abc / 1`] = `
exports[`base parser Errors EOF_IN_TAG <template><div id=abc / 1`] = `
Object {
"children": Array [
Object {
@ -3225,7 +3153,7 @@ Object {
}
`;
exports[`base parser onError option EOF_IN_TAG <template><div id=abc 1`] = `
exports[`base parser Errors EOF_IN_TAG <template><div id=abc 1`] = `
Object {
"children": Array [
Object {
@ -3327,7 +3255,7 @@ Object {
}
`;
exports[`base parser onError option INCORRECTLY_CLOSED_COMMENT <template><!--comment--!></template> 1`] = `
exports[`base parser Errors INCORRECTLY_CLOSED_COMMENT <template><!--comment--!></template> 1`] = `
Object {
"children": Array [
Object {
@ -3388,7 +3316,7 @@ Object {
}
`;
exports[`base parser onError option INCORRECTLY_OPENED_COMMENT <!DOCTYPE html> 1`] = `
exports[`base parser Errors INCORRECTLY_OPENED_COMMENT <!DOCTYPE html> 1`] = `
Object {
"children": Array [
Object {
@ -3426,7 +3354,7 @@ Object {
}
`;
exports[`base parser onError option INCORRECTLY_OPENED_COMMENT <template><!></template> 1`] = `
exports[`base parser Errors INCORRECTLY_OPENED_COMMENT <template><!></template> 1`] = `
Object {
"children": Array [
Object {
@ -3487,7 +3415,7 @@ Object {
}
`;
exports[`base parser onError option INCORRECTLY_OPENED_COMMENT <template><!-></template> 1`] = `
exports[`base parser Errors INCORRECTLY_OPENED_COMMENT <template><!-></template> 1`] = `
Object {
"children": Array [
Object {
@ -3548,7 +3476,7 @@ Object {
}
`;
exports[`base parser onError option INCORRECTLY_OPENED_COMMENT <template><!ELEMENT br EMPTY></template> 1`] = `
exports[`base parser Errors INCORRECTLY_OPENED_COMMENT <template><!ELEMENT br EMPTY></template> 1`] = `
Object {
"children": Array [
Object {
@ -3609,7 +3537,7 @@ Object {
}
`;
exports[`base parser onError option INVALID_FIRST_CHARACTER_OF_TAG_NAME <template></<2F>></template> 1`] = `
exports[`base parser Errors INVALID_FIRST_CHARACTER_OF_TAG_NAME <template></<2F>></template> 1`] = `
Object {
"children": Array [
Object {
@ -3670,7 +3598,7 @@ Object {
}
`;
exports[`base parser onError option INVALID_FIRST_CHARACTER_OF_TAG_NAME <template><<3C>></template> 1`] = `
exports[`base parser Errors INVALID_FIRST_CHARACTER_OF_TAG_NAME <template><<3C>></template> 1`] = `
Object {
"children": Array [
Object {
@ -3732,7 +3660,7 @@ Object {
}
`;
exports[`base parser onError option INVALID_FIRST_CHARACTER_OF_TAG_NAME <template>{{a < b}}</template> 1`] = `
exports[`base parser Errors INVALID_FIRST_CHARACTER_OF_TAG_NAME <template>{{a < b}}</template> 1`] = `
Object {
"children": Array [
Object {
@ -3794,7 +3722,7 @@ Object {
}
`;
exports[`base parser onError option INVALID_FIRST_CHARACTER_OF_TAG_NAME <template>a < b</template> 1`] = `
exports[`base parser Errors INVALID_FIRST_CHARACTER_OF_TAG_NAME <template>a < b</template> 1`] = `
Object {
"children": Array [
Object {
@ -3856,7 +3784,7 @@ Object {
}
`;
exports[`base parser onError option INVALID_FIRST_CHARACTER_OF_TAG_NAME <template>a </ b</template> 1`] = `
exports[`base parser Errors INVALID_FIRST_CHARACTER_OF_TAG_NAME <template>a </ b</template> 1`] = `
Object {
"children": Array [
Object {
@ -3935,7 +3863,7 @@ Object {
}
`;
exports[`base parser onError option MISSING_ATTRIBUTE_VALUE <template><div id= /></div></template> 1`] = `
exports[`base parser Errors MISSING_ATTRIBUTE_VALUE <template><div id= /></div></template> 1`] = `
Object {
"children": Array [
Object {
@ -4037,7 +3965,7 @@ Object {
}
`;
exports[`base parser onError option MISSING_ATTRIBUTE_VALUE <template><div id= ></div></template> 1`] = `
exports[`base parser Errors MISSING_ATTRIBUTE_VALUE <template><div id= ></div></template> 1`] = `
Object {
"children": Array [
Object {
@ -4122,7 +4050,7 @@ Object {
}
`;
exports[`base parser onError option MISSING_ATTRIBUTE_VALUE <template><div id=></div></template> 1`] = `
exports[`base parser Errors MISSING_ATTRIBUTE_VALUE <template><div id=></div></template> 1`] = `
Object {
"children": Array [
Object {
@ -4207,7 +4135,7 @@ Object {
}
`;
exports[`base parser onError option MISSING_END_TAG_NAME <template></></template> 1`] = `
exports[`base parser Errors MISSING_END_TAG_NAME <template></></template> 1`] = `
Object {
"children": Array [
Object {
@ -4250,7 +4178,7 @@ Object {
}
`;
exports[`base parser onError option MISSING_SEMICOLON_AFTER_CHARACTER_REFERENCE <template>&#40</template> 1`] = `
exports[`base parser Errors MISSING_SEMICOLON_AFTER_CHARACTER_REFERENCE <template>&#40</template> 1`] = `
Object {
"children": Array [
Object {
@ -4312,7 +4240,7 @@ Object {
}
`;
exports[`base parser onError option MISSING_SEMICOLON_AFTER_CHARACTER_REFERENCE <template>&#x40</template> 1`] = `
exports[`base parser Errors MISSING_SEMICOLON_AFTER_CHARACTER_REFERENCE <template>&#x40</template> 1`] = `
Object {
"children": Array [
Object {
@ -4374,7 +4302,7 @@ Object {
}
`;
exports[`base parser onError option MISSING_SEMICOLON_AFTER_CHARACTER_REFERENCE <template>&amp</template> 1`] = `
exports[`base parser Errors MISSING_SEMICOLON_AFTER_CHARACTER_REFERENCE <template>&amp</template> 1`] = `
Object {
"children": Array [
Object {
@ -4436,7 +4364,7 @@ Object {
}
`;
exports[`base parser onError option MISSING_WHITESPACE_BETWEEN_ATTRIBUTES <template><div id="foo"\\x0d;\\x0a;class="bar"></div></template> 1`] = `
exports[`base parser Errors MISSING_WHITESPACE_BETWEEN_ATTRIBUTES <template><div id="foo"\\x0d;\\x0a;class="bar"></div></template> 1`] = `
Object {
"children": Array [
Object {
@ -4576,7 +4504,7 @@ class=\\"bar\\"></div></template>",
}
`;
exports[`base parser onError option MISSING_WHITESPACE_BETWEEN_ATTRIBUTES <template><div id="foo"class="bar"></div></template> 1`] = `
exports[`base parser Errors MISSING_WHITESPACE_BETWEEN_ATTRIBUTES <template><div id="foo"class="bar"></div></template> 1`] = `
Object {
"children": Array [
Object {
@ -4713,7 +4641,7 @@ Object {
}
`;
exports[`base parser onError option NESTED_COMMENT <template><!--a<!-- 1`] = `
exports[`base parser Errors NESTED_COMMENT <template><!--a<!-- 1`] = `
Object {
"children": Array [
Object {
@ -4774,7 +4702,7 @@ Object {
}
`;
exports[`base parser onError option NESTED_COMMENT <template><!--a<!--></template> 1`] = `
exports[`base parser Errors NESTED_COMMENT <template><!--a<!--></template> 1`] = `
Object {
"children": Array [
Object {
@ -4835,7 +4763,7 @@ Object {
}
`;
exports[`base parser onError option NESTED_COMMENT <template><!--a<!--b<!--c--></template> 1`] = `
exports[`base parser Errors NESTED_COMMENT <template><!--a<!--b<!--c--></template> 1`] = `
Object {
"children": Array [
Object {
@ -4896,7 +4824,7 @@ Object {
}
`;
exports[`base parser onError option NESTED_COMMENT <template><!--a<!--b--></template> 1`] = `
exports[`base parser Errors NESTED_COMMENT <template><!--a<!--b--></template> 1`] = `
Object {
"children": Array [
Object {
@ -4957,7 +4885,7 @@ Object {
}
`;
exports[`base parser onError option NONCHARACTER_CHARACTER_REFERENCE <template>&#x1FFFF;</template> 1`] = `
exports[`base parser Errors NONCHARACTER_CHARACTER_REFERENCE <template>&#x1FFFF;</template> 1`] = `
Object {
"children": Array [
Object {
@ -5019,7 +4947,7 @@ Object {
}
`;
exports[`base parser onError option NONCHARACTER_CHARACTER_REFERENCE <template>&#xFFFE;</template> 1`] = `
exports[`base parser Errors NONCHARACTER_CHARACTER_REFERENCE <template>&#xFFFE;</template> 1`] = `
Object {
"children": Array [
Object {
@ -5081,7 +5009,7 @@ Object {
}
`;
exports[`base parser onError option NULL_CHARACTER_REFERENCE <template>&#0000;</template> 1`] = `
exports[`base parser Errors NULL_CHARACTER_REFERENCE <template>&#0000;</template> 1`] = `
Object {
"children": Array [
Object {
@ -5143,7 +5071,7 @@ Object {
}
`;
exports[`base parser onError option SURROGATE_CHARACTER_REFERENCE <template>&#xD800;</template> 1`] = `
exports[`base parser Errors SURROGATE_CHARACTER_REFERENCE <template>&#xD800;</template> 1`] = `
Object {
"children": Array [
Object {
@ -5205,7 +5133,7 @@ Object {
}
`;
exports[`base parser onError option UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME <template><div a"bc=''></div></template> 1`] = `
exports[`base parser Errors UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME <template><div a"bc=''></div></template> 1`] = `
Object {
"children": Array [
Object {
@ -5307,7 +5235,7 @@ Object {
}
`;
exports[`base parser onError option UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME <template><div a'bc=''></div></template> 1`] = `
exports[`base parser Errors UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME <template><div a'bc=''></div></template> 1`] = `
Object {
"children": Array [
Object {
@ -5409,7 +5337,7 @@ Object {
}
`;
exports[`base parser onError option UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME <template><div a<bc=''></div></template> 1`] = `
exports[`base parser Errors UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME <template><div a<bc=''></div></template> 1`] = `
Object {
"children": Array [
Object {
@ -5511,7 +5439,7 @@ Object {
}
`;
exports[`base parser onError option UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE <template><div foo=bar"></div></template> 1`] = `
exports[`base parser Errors UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE <template><div foo=bar"></div></template> 1`] = `
Object {
"children": Array [
Object {
@ -5613,7 +5541,7 @@ Object {
}
`;
exports[`base parser onError option UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE <template><div foo=bar'></div></template> 1`] = `
exports[`base parser Errors UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE <template><div foo=bar'></div></template> 1`] = `
Object {
"children": Array [
Object {
@ -5715,7 +5643,7 @@ Object {
}
`;
exports[`base parser onError option UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE <template><div foo=bar<div></div></template> 1`] = `
exports[`base parser Errors UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE <template><div foo=bar<div></div></template> 1`] = `
Object {
"children": Array [
Object {
@ -5817,7 +5745,7 @@ Object {
}
`;
exports[`base parser onError option UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE <template><div foo=bar=baz></div></template> 1`] = `
exports[`base parser Errors UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE <template><div foo=bar=baz></div></template> 1`] = `
Object {
"children": Array [
Object {
@ -5919,7 +5847,7 @@ Object {
}
`;
exports[`base parser onError option UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE <template><div foo=bar\`></div></template> 1`] = `
exports[`base parser Errors UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE <template><div foo=bar\`></div></template> 1`] = `
Object {
"children": Array [
Object {
@ -6021,7 +5949,7 @@ Object {
}
`;
exports[`base parser onError option UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME <template><div =></div></template> 1`] = `
exports[`base parser Errors UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME <template><div =></div></template> 1`] = `
Object {
"children": Array [
Object {
@ -6106,7 +6034,7 @@ Object {
}
`;
exports[`base parser onError option UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME <template><div =foo=bar></div></template> 1`] = `
exports[`base parser Errors UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME <template><div =foo=bar></div></template> 1`] = `
Object {
"children": Array [
Object {
@ -6208,7 +6136,7 @@ Object {
}
`;
exports[`base parser onError option UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME <template><?xml?></template> 1`] = `
exports[`base parser Errors UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME <template><?xml?></template> 1`] = `
Object {
"children": Array [
Object {
@ -6269,7 +6197,7 @@ Object {
}
`;
exports[`base parser onError option UNEXPECTED_SOLIDUS_IN_TAG <template><div a/b></div></template> 1`] = `
exports[`base parser Errors UNEXPECTED_SOLIDUS_IN_TAG <template><div a/b></div></template> 1`] = `
Object {
"children": Array [
Object {
@ -6372,7 +6300,7 @@ Object {
}
`;
exports[`base parser onError option UNKNOWN_NAMED_CHARACTER_REFERENCE <template>&unknown;</template> 1`] = `
exports[`base parser Errors UNKNOWN_NAMED_CHARACTER_REFERENCE <template>&unknown;</template> 1`] = `
Object {
"children": Array [
Object {
@ -6434,7 +6362,7 @@ Object {
}
`;
exports[`base parser onError option X_INVALID_END_TAG <svg><![CDATA[</div>]]></svg> 1`] = `
exports[`base parser Errors X_INVALID_END_TAG <svg><![CDATA[</div>]]></svg> 1`] = `
Object {
"children": Array [
Object {
@ -6496,7 +6424,7 @@ Object {
}
`;
exports[`base parser onError option X_INVALID_END_TAG <svg><!--</div>--></svg> 1`] = `
exports[`base parser Errors X_INVALID_END_TAG <svg><!--</div>--></svg> 1`] = `
Object {
"children": Array [
Object {
@ -6557,7 +6485,7 @@ Object {
}
`;
exports[`base parser onError option X_INVALID_END_TAG <template></div></div></template> 1`] = `
exports[`base parser Errors X_INVALID_END_TAG <template></div></div></template> 1`] = `
Object {
"children": Array [
Object {
@ -6600,7 +6528,7 @@ Object {
}
`;
exports[`base parser onError option X_INVALID_END_TAG <template></div></template> 1`] = `
exports[`base parser Errors X_INVALID_END_TAG <template></div></template> 1`] = `
Object {
"children": Array [
Object {
@ -6643,7 +6571,7 @@ Object {
}
`;
exports[`base parser onError option X_INVALID_END_TAG <template>{{'</div>'}}</template> 1`] = `
exports[`base parser Errors X_INVALID_END_TAG <template>{{'</div>'}}</template> 1`] = `
Object {
"children": Array [
Object {
@ -6705,7 +6633,7 @@ Object {
}
`;
exports[`base parser onError option X_INVALID_END_TAG <textarea></div></textarea> 1`] = `
exports[`base parser Errors X_INVALID_END_TAG <textarea></div></textarea> 1`] = `
Object {
"children": Array [
Object {
@ -6767,7 +6695,7 @@ Object {
}
`;
exports[`base parser onError option X_MISSING_END_TAG <template><div> 1`] = `
exports[`base parser Errors X_MISSING_END_TAG <template><div> 1`] = `
Object {
"children": Array [
Object {
@ -6833,7 +6761,7 @@ Object {
}
`;
exports[`base parser onError option X_MISSING_END_TAG <template><div></template> 1`] = `
exports[`base parser Errors X_MISSING_END_TAG <template><div></template> 1`] = `
Object {
"children": Array [
Object {
@ -6899,7 +6827,7 @@ Object {
}
`;
exports[`base parser onError option X_MISSING_INTERPOLATION_END {{ 1`] = `
exports[`base parser Errors X_MISSING_INTERPOLATION_END {{ 1`] = `
Object {
"children": Array [
Object {
@ -6938,7 +6866,7 @@ Object {
}
`;
exports[`base parser onError option X_MISSING_INTERPOLATION_END {{ foo 1`] = `
exports[`base parser Errors X_MISSING_INTERPOLATION_END {{ foo 1`] = `
Object {
"children": Array [
Object {
@ -6977,7 +6905,7 @@ Object {
}
`;
exports[`base parser onError option X_MISSING_INTERPOLATION_END {{}} 1`] = `
exports[`base parser Errors X_MISSING_INTERPOLATION_END {{}} 1`] = `
Object {
"children": Array [
Object {
@ -7016,6 +6944,78 @@ Object {
}
`;
exports[`base parser invalid html 1`] = `
Object {
"children": Array [
Object {
"children": Array [
Object {
"children": Array [],
"isSelfClosing": false,
"loc": Object {
"end": Object {
"column": 1,
"line": 3,
"offset": 13,
},
"source": "<span>
",
"start": Object {
"column": 1,
"line": 2,
"offset": 6,
},
},
"ns": 0,
"props": Array [],
"tag": "span",
"tagType": 0,
"type": 2,
},
],
"isSelfClosing": false,
"loc": Object {
"end": Object {
"column": 7,
"line": 3,
"offset": 19,
},
"source": "<div>
<span>
</div>",
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"ns": 0,
"props": Array [],
"tag": "div",
"tagType": 0,
"type": 2,
},
],
"loc": Object {
"end": Object {
"column": 8,
"line": 4,
"offset": 27,
},
"source": "<div>
<span>
</div>
</span>",
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": 6,
}
`;
exports[`base parser self closing multiple tag 1`] = `
Object {
"children": Array [

View File

@ -9,7 +9,8 @@ import {
Namespaces,
NodeTypes,
Position,
TextNode
TextNode,
AttributeNode
} from '../src/ast'
describe('base parser', () => {
@ -175,6 +176,84 @@ describe('base parser', () => {
})
})
test('HTML entities compatibility in text (https://html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state).', () => {
const spy = jest.fn()
const ast = parse('&ampersand;', {
namedCharacterReferences: { amp: '&' },
onError: spy
})
const text = ast.children[0] as TextNode
expect(text).toStrictEqual({
type: NodeTypes.TEXT,
content: '&ersand;',
isEmpty: false,
loc: {
start: { offset: 0, line: 1, column: 1 },
end: { offset: 11, line: 1, column: 12 },
source: '&ampersand;'
}
})
expect(spy.mock.calls).toEqual([
[
ParserErrorTypes.MISSING_SEMICOLON_AFTER_CHARACTER_REFERENCE,
{ offset: 4, line: 1, column: 5 }
]
])
})
test('HTML entities compatibility in attribute (https://html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state).', () => {
const spy = jest.fn()
const ast = parse(
'<div a="&ampersand;" b="&amp;ersand;" c="&amp!"></div>',
{
namedCharacterReferences: { amp: '&', 'amp;': '&' },
onError: spy
}
)
const element = ast.children[0] as ElementNode
const text1 = (element.props[0] as AttributeNode).value
const text2 = (element.props[1] as AttributeNode).value
const text3 = (element.props[2] as AttributeNode).value
expect(text1).toStrictEqual({
type: NodeTypes.TEXT,
content: '&ampersand;',
isEmpty: false,
loc: {
start: { offset: 7, line: 1, column: 8 },
end: { offset: 20, line: 1, column: 21 },
source: '"&ampersand;"'
}
})
expect(text2).toStrictEqual({
type: NodeTypes.TEXT,
content: '&ersand;',
isEmpty: false,
loc: {
start: { offset: 23, line: 1, column: 24 },
end: { offset: 37, line: 1, column: 38 },
source: '"&amp;ersand;"'
}
})
expect(text3).toStrictEqual({
type: NodeTypes.TEXT,
content: '&!',
isEmpty: false,
loc: {
start: { offset: 40, line: 1, column: 41 },
end: { offset: 47, line: 1, column: 48 },
source: '"&amp!"'
}
})
expect(spy.mock.calls).toEqual([
[
ParserErrorTypes.MISSING_SEMICOLON_AFTER_CHARACTER_REFERENCE,
{ offset: 45, line: 1, column: 46 }
]
])
})
test('Some control character reference should be replaced.', () => {
const spy = jest.fn()
const ast = parse('&#x86;', { onError: spy })

View File

@ -0,0 +1 @@
// TODO

View File

@ -0,0 +1 @@
// TODO

View File

@ -0,0 +1 @@
// TODO

View File

@ -0,0 +1 @@
// TODO

View File

@ -0,0 +1 @@
// TODO

View File

@ -0,0 +1 @@
// TODO

View File

@ -0,0 +1 @@
// TODO

View File

@ -0,0 +1 @@
// TODO

View File

@ -0,0 +1 @@
// TODO

View File

@ -1,3 +1,3 @@
export { parse, ParserOptions, TextModes } from './parser'
export { ParserErrorTypes } from './errorTypes'
export * from './ast'
export * from './errorTypes'

View File

@ -0,0 +1 @@
// TODO

View File

@ -0,0 +1 @@
// TODO

View File

@ -0,0 +1 @@
// TODO

View File

@ -0,0 +1 @@
// TODO

View File

@ -35,10 +35,18 @@ export const defaultParserOptions: Required<ParserOptions> = {
getNamespace: () => Namespaces.HTML,
getTextMode: () => TextModes.DATA,
isVoidTag: () => false,
namedCharacterReferences: {},
namedCharacterReferences: {
'gt;': '>',
'lt;': '<',
'amp;': '&',
'apos;': "'",
'quot;': '"'
},
onError(code: ParserErrorTypes, loc: Position): void {
const error: any = new SyntaxError(
`${errorMessages[code]} (${loc.line}:${loc.column})`
`${__DEV__ || !__BROWSER__ ? errorMessages[code] : code} (${loc.line}:${
loc.column
})`
)
error.code = code
error.loc = loc
@ -658,7 +666,7 @@ function parseTextData(
return text
}
// DATA or RCDATA.
// DATA or RCDATA. Entity decoding required.
const end = context.offset + length
let text: string = ''
@ -767,7 +775,6 @@ function parseTextData(
}
}
}
return text
}

View File

@ -0,0 +1 @@
// TODO

View File

@ -3,7 +3,6 @@ import {
NodeTypes,
ElementNode,
TextNode,
AttributeNode,
ParserErrorTypes,
ExpressionNode,
ElementTypes
@ -104,86 +103,6 @@ describe('DOM parser', () => {
}
})
})
test('HTML entities compatibility in text (https://html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state).', () => {
const spy = jest.fn()
const ast = parse('&ampersand;', {
...parserOptions,
namedCharacterReferences: { amp: '&' },
onError: spy
})
const text = ast.children[0] as TextNode
expect(text).toStrictEqual({
type: NodeTypes.TEXT,
content: '&ersand;',
isEmpty: false,
loc: {
start: { offset: 0, line: 1, column: 1 },
end: { offset: 11, line: 1, column: 12 },
source: '&ampersand;'
}
})
expect(spy.mock.calls).toEqual([
[
ParserErrorTypes.MISSING_SEMICOLON_AFTER_CHARACTER_REFERENCE,
{ offset: 4, line: 1, column: 5 }
]
])
})
test('HTML entities compatibility in attribute (https://html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state).', () => {
const spy = jest.fn()
const ast = parse(
'<div a="&ampersand;" b="&amp;ersand;" c="&amp!"></div>',
{
...parserOptions,
namedCharacterReferences: { amp: '&', 'amp;': '&' },
onError: spy
}
)
const element = ast.children[0] as ElementNode
const text1 = (element.props[0] as AttributeNode).value
const text2 = (element.props[1] as AttributeNode).value
const text3 = (element.props[2] as AttributeNode).value
expect(text1).toStrictEqual({
type: NodeTypes.TEXT,
content: '&ampersand;',
isEmpty: false,
loc: {
start: { offset: 7, line: 1, column: 8 },
end: { offset: 20, line: 1, column: 21 },
source: '"&ampersand;"'
}
})
expect(text2).toStrictEqual({
type: NodeTypes.TEXT,
content: '&ersand;',
isEmpty: false,
loc: {
start: { offset: 23, line: 1, column: 24 },
end: { offset: 37, line: 1, column: 38 },
source: '"&amp;ersand;"'
}
})
expect(text3).toStrictEqual({
type: NodeTypes.TEXT,
content: '&!',
isEmpty: false,
loc: {
start: { offset: 40, line: 1, column: 41 },
end: { offset: 47, line: 1, column: 48 },
source: '"&amp!"'
}
})
expect(spy.mock.calls).toEqual([
[
ParserErrorTypes.MISSING_SEMICOLON_AFTER_CHARACTER_REFERENCE,
{ offset: 45, line: 1, column: 46 }
]
])
})
})
describe('Interpolation', () => {

View File

@ -0,0 +1 @@
// TODO

View File

@ -0,0 +1 @@
// TODO

View File

@ -0,0 +1 @@
// TODO

View File

@ -0,0 +1 @@
// TODO

View File

@ -0,0 +1 @@
// TODO

View File

@ -1,4 +1,8 @@
// TODO
export * from '@vue/compiler-core'
export { parserOptionsMinimal } from './parserOptionsMinimal'
export { parserOptionsStandard } from './parserOptionsStandard'
import { parserOptionsMinimal } from './parserOptionsMinimal'
import { parserOptionsStandard } from './parserOptionsStandard'
export const parserOptions = __BROWSER__
? parserOptionsMinimal
: parserOptionsStandard

View File

@ -81,13 +81,5 @@ export const parserOptionsMinimal: ParserOptions = {
isVoidTag(tag: string): boolean {
return VOID_TAG_RE.test(tag)
},
namedCharacterReferences: {
'gt;': '>',
'lt;': '<',
'amp;': '&',
'apos;': "'",
'quot;': '"'
}
}

View File

@ -1,8 +1,8 @@
// Global compile-time constants
declare var __DEV__: boolean
declare var __JSDOM__: boolean
declare var __BROWSER__: boolean
// Feature flags
declare var __FEATURE_OPTIONS__: boolean
declare var __FEATURE_PRODUCTION_TIP__: boolean
declare var __FEATURE_SUSPENSE__: boolean

View File

@ -7,7 +7,7 @@
export * from '@vue/compiler-dom'
export * from '@vue/runtime-dom'
if (__FEATURE_PRODUCTION_TIP__) {
if (__BROWSER__ && __DEV__) {
console[console.info ? 'info' : 'log'](
`You are running a development build of Vue.\n` +
`Make sure to use the production build (*.prod.js) when deploying for production.`

View File

@ -134,9 +134,8 @@ function createReplacePlugin(isProduction, isBunlderESMBuild, isBrowserBuild) {
`process.env.NODE_ENV !== 'production'`
: // hard coded dev/prod builds
!isProduction,
// show production tip?
// should only do this for dev AND browser-targeting builds.
__FEATURE_PRODUCTION_TIP__: !isProduction && isBrowserBuild,
// If the build is expected to run directly in the browser (global / esm-browser builds)
__BROWSER__: isBrowserBuild,
// support options?
// the lean build drops options related code with buildOptions.lean: true
__FEATURE_OPTIONS__: !packageOptions.lean,