From 132cef906300e75a8b908099cdffee04d8ae1e9d Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 17 Sep 2019 11:57:25 -0400 Subject: [PATCH] refactor: further tweak compiler layers --- jest.config.js | 2 +- .../__snapshots__/parse.spec.ts.snap | 332 +++++++++--------- .../compiler-core/__tests__/parse.spec.ts | 81 ++++- packages/compiler-core/src/assert.ts | 0 packages/compiler-core/src/codegen.ts | 1 + .../compiler-core/src/directives/vBind.ts | 1 + packages/compiler-core/src/directives/vFor.ts | 1 + packages/compiler-core/src/directives/vIf.ts | 1 + .../compiler-core/src/directives/vModel.ts | 1 + packages/compiler-core/src/directives/vOn.ts | 1 + packages/compiler-core/src/directives/vPre.ts | 1 + .../compiler-core/src/directives/vSlot.ts | 1 + .../compiler-core/src/directives/vText.ts | 1 + packages/compiler-core/src/index.ts | 2 +- .../compiler-core/src/optimizations/blocks.ts | 1 + .../compiler-core/src/optimizations/class.ts | 1 + .../src/optimizations/patchFlag.ts | 1 + .../compiler-core/src/optimizations/style.ts | 1 + packages/compiler-core/src/parser.ts | 15 +- packages/compiler-core/src/transform.ts | 1 + packages/compiler-dom/__tests__/parse.spec.ts | 81 ----- .../compiler-dom/src/directives/vCloak.ts | 1 + packages/compiler-dom/src/directives/vHtml.ts | 1 + .../compiler-dom/src/directives/vModel.ts | 1 + packages/compiler-dom/src/directives/vOn.ts | 1 + packages/compiler-dom/src/directives/vShow.ts | 1 + packages/compiler-dom/src/index.ts | 8 +- .../compiler-dom/src/parserOptionsMinimal.ts | 8 - packages/global.d.ts | 2 +- packages/vue/src/index.ts | 2 +- rollup.config.js | 5 +- 31 files changed, 288 insertions(+), 269 deletions(-) delete mode 100644 packages/compiler-core/src/assert.ts diff --git a/jest.config.js b/jest.config.js index 956e0f7a429..6c322c83421 100644 --- a/jest.config.js +++ b/jest.config.js @@ -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', diff --git a/packages/compiler-core/__tests__/__snapshots__/parse.spec.ts.snap b/packages/compiler-core/__tests__/__snapshots__/parse.spec.ts.snap index f488bac6adb..14e2e9d9bc0 100644 --- a/packages/compiler-core/__tests__/__snapshots__/parse.spec.ts.snap +++ b/packages/compiler-core/__tests__/__snapshots__/parse.spec.ts.snap @@ -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": " -", - "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": "
- -
", - "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": "
- -
-
", - "start": Object { - "column": 1, - "line": 1, - "offset": 0, - }, - }, - "type": 6, -} -`; - -exports[`base parser onError option ABRUPT_CLOSING_OF_EMPTY_COMMENT 1`] = ` +exports[`base parser Errors ABRUPT_CLOSING_OF_EMPTY_COMMENT 1`] = ` Object { "children": Array [ Object { @@ -133,7 +61,7 @@ Object { } `; -exports[`base parser onError option ABRUPT_CLOSING_OF_EMPTY_COMMENT 1`] = ` +exports[`base parser Errors ABRUPT_CLOSING_OF_EMPTY_COMMENT 1`] = ` Object { "children": Array [ Object { @@ -194,7 +122,7 @@ Object { } `; -exports[`base parser onError option ABRUPT_CLOSING_OF_EMPTY_COMMENT 1`] = ` +exports[`base parser Errors ABRUPT_CLOSING_OF_EMPTY_COMMENT 1`] = ` Object { "children": Array [ Object { @@ -255,7 +183,7 @@ Object { } `; -exports[`base parser onError option ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE 1`] = ` +exports[`base parser Errors ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE 1`] = ` Object { "children": Array [ Object { @@ -334,7 +262,7 @@ Object { } `; -exports[`base parser onError option ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE 1`] = ` +exports[`base parser Errors ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE 1`] = ` Object { "children": Array [ Object { @@ -413,7 +341,7 @@ Object { } `; -exports[`base parser onError option ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE 1`] = ` +exports[`base parser Errors ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE 1`] = ` Object { "children": Array [ Object { @@ -492,7 +420,7 @@ Object { } `; -exports[`base parser onError option ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE 1`] = ` +exports[`base parser Errors ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE 1`] = ` Object { "children": Array [ Object { @@ -571,7 +499,7 @@ Object { } `; -exports[`base parser onError option ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE 1`] = ` +exports[`base parser Errors ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE 1`] = ` Object { "children": Array [ Object { @@ -633,7 +561,7 @@ Object { } `; -exports[`base parser onError option ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE 1`] = ` +exports[`base parser Errors ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE 1`] = ` Object { "children": Array [ Object { @@ -695,7 +623,7 @@ Object { } `; -exports[`base parser onError option ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE 1`] = ` +exports[`base parser Errors ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE 1`] = ` Object { "children": Array [ Object { @@ -757,7 +685,7 @@ Object { } `; -exports[`base parser onError option ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE 1`] = ` +exports[`base parser Errors ABSENCE_OF_DIGITS_IN_NUMERIC_CHARACTER_REFERENCE 1`] = ` Object { "children": Array [ Object { @@ -819,7 +747,7 @@ Object { } `; -exports[`base parser onError option CDATA_IN_HTML_CONTENT 1`] = ` +exports[`base parser Errors CDATA_IN_HTML_CONTENT 1`] = ` Object { "children": Array [ Object { @@ -880,7 +808,7 @@ Object { } `; -exports[`base parser onError option CDATA_IN_HTML_CONTENT 1`] = ` +exports[`base parser Errors CDATA_IN_HTML_CONTENT 1`] = ` Object { "children": Array [ Object { @@ -965,7 +893,7 @@ Object { } `; -exports[`base parser onError option CHARACTER_REFERENCE_OUTSIDE_UNICODE_RANGE 1`] = ` +exports[`base parser Errors CHARACTER_REFERENCE_OUTSIDE_UNICODE_RANGE 1`] = ` Object { "children": Array [ Object { @@ -1027,7 +955,7 @@ Object { } `; -exports[`base parser onError option CONTROL_CHARACTER_REFERENCE 1`] = ` +exports[`base parser Errors CONTROL_CHARACTER_REFERENCE 1`] = ` Object { "children": Array [ Object { @@ -1089,7 +1017,7 @@ Object { } `; -exports[`base parser onError option CONTROL_CHARACTER_REFERENCE 1`] = ` +exports[`base parser Errors CONTROL_CHARACTER_REFERENCE 1`] = ` Object { "children": Array [ Object { @@ -1151,7 +1079,7 @@ Object { } `; -exports[`base parser onError option DUPLICATE_ATTRIBUTE 1`] = ` +exports[`base parser Errors DUPLICATE_ATTRIBUTE 1`] = ` Object { "children": Array [ Object { @@ -1288,7 +1216,7 @@ Object { } `; -exports[`base parser onError option END_TAG_WITH_ATTRIBUTES 1`] = ` +exports[`base parser Errors END_TAG_WITH_ATTRIBUTES 1`] = ` Object { "children": Array [ Object { @@ -1354,7 +1282,7 @@ Object { } `; -exports[`base parser onError option END_TAG_WITH_TRAILING_SOLIDUS 1`] = ` +exports[`base parser Errors END_TAG_WITH_TRAILING_SOLIDUS 1`] = ` Object { "children": Array [ Object { @@ -1420,7 +1348,7 @@ Object { } `; -exports[`base parser onError option EOF_BEFORE_TAG_NAME