From 913f047ba38873c428524313e8a2dbd6e37ce5e9 Mon Sep 17 00:00:00 2001 From: Jamie Stumme Date: Thu, 21 Nov 2019 18:43:25 -0600 Subject: [PATCH 01/17] Support composition api variable for provider --- packages/create-instance/create-instance.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/create-instance/create-instance.js b/packages/create-instance/create-instance.js index 562c1f852..c8db93446 100644 --- a/packages/create-instance/create-instance.js +++ b/packages/create-instance/create-instance.js @@ -82,6 +82,7 @@ export default function createInstance( const parentComponentOptions = options.parentComponent || {} parentComponentOptions.provide = options.provide + parentComponentOptions._provided = options.provide parentComponentOptions.$_doNotStubChildren = true parentComponentOptions._isFunctionalContainer = componentOptions.functional parentComponentOptions.render = function(h) { From 661ececa801b809396ab52fcdffe9f880c29ca71 Mon Sep 17 00:00:00 2001 From: Jamie Stumme Date: Fri, 22 Nov 2019 06:03:26 -0600 Subject: [PATCH 02/17] Add files for flow support in vscode and updated flow to 0.111.x --- .vscode/settings.json | 4 ++++ package.json | 2 +- yarn.lock | 7 ++++--- 3 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..2ed11fc0d --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "javascript.validate.enable": false, + "flow.pathToFlow": "${workspaceFolder}/node_modules/.bin/flow" +} \ No newline at end of file diff --git a/package.json b/package.json index 2b484ef4a..7b83a1a2b 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "eslint-plugin-flowtype": "^2.46.1", "eslint-plugin-markdown": "^1.0.0-beta.6", "eslint-plugin-vue-libs": "^2.1.0", - "flow-bin": "^0.66.0", + "flow-bin": "^0.111.0", "jsdom": "^12.0.0", "jsdom-global": "^3.0.2", "karma": "^3.1.4", diff --git a/yarn.lock b/yarn.lock index a3b77dca7..a465ba1e1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4491,9 +4491,10 @@ flatten@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782" -flow-bin@^0.66.0: - version "0.66.0" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.66.0.tgz#a96dde7015dc3343fd552a7b4963c02be705ca26" +flow-bin@^0.111.0: + version "0.111.3" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.111.3.tgz#8653a413400ebc966097a47c81fb4e6b722a5921" + integrity sha512-Gn27aRTjSFicukZ/pq3raRERmSk9UWszhIK9eNtj6843L54YtK+jk2OkQWV70+VKi9LmWyfItCkhwoIVy7L2lA== flow-remove-types-no-whitespace@^1.0.3: version "1.0.5" From 358633686857fba511ae08de1e91701f8d543025 Mon Sep 17 00:00:00 2001 From: Jamie Stumme Date: Fri, 22 Nov 2019 06:39:38 -0600 Subject: [PATCH 03/17] Add test for injection on composition api component. --- package.json | 1 + .../component-with-inject-composition.vue | 22 +++++++++++++++++++ test/specs/mounting-options/provide.spec.js | 18 +++++++++++++++ yarn.lock | 12 ++++++++++ 4 files changed, 53 insertions(+) create mode 100644 test/resources/components/component-with-inject-composition.vue diff --git a/package.json b/package.json index 7b83a1a2b..2f0fa51c5 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "test:types": "tsc -p packages/test-utils/types && tsc -p packages/server-test-utils/types" }, "dependencies": { + "@vue/composition-api": "^0.3.2", "babel-core": "^6.26.0", "babel-eslint": "^8.2.2", "babel-loader": "^7.1.3", diff --git a/test/resources/components/component-with-inject-composition.vue b/test/resources/components/component-with-inject-composition.vue new file mode 100644 index 000000000..fe1a48d6a --- /dev/null +++ b/test/resources/components/component-with-inject-composition.vue @@ -0,0 +1,22 @@ + + + diff --git a/test/specs/mounting-options/provide.spec.js b/test/specs/mounting-options/provide.spec.js index 97bb9d32c..8cb3f3627 100644 --- a/test/specs/mounting-options/provide.spec.js +++ b/test/specs/mounting-options/provide.spec.js @@ -1,8 +1,11 @@ import { config } from '~vue/test-utils' +import { createLocalVue } from '~vue/test-utils' import ComponentWithInject from '~resources/components/component-with-inject.vue' +import CompositionComponentWithInject from '~resources/components/component-with-inject-composition.vue' import { injectSupported } from '~resources/utils' import { describeWithShallowAndMount } from '~resources/utils' import { itDoNotRunIf, itSkipIf } from 'conditional-specs' +import VueCompositionApi from '@vue/composition-api' describeWithShallowAndMount('options.provide', mountingMethod => { let configProvideSave @@ -86,6 +89,21 @@ describeWithShallowAndMount('options.provide', mountingMethod => { } ) + itDoNotRunIf( + !injectSupported, + 'injects in a composition api component', + () => { + const localVue = createLocalVue() + localVue.use(VueCompositionApi) + const wrapper = mountingMethod(CompositionComponentWithInject, { + provide: { fromMount: '_' }, + localVue + }) + + expect(wrapper.html()).to.contain('_') + } + ) + it('config with function throws', () => { config.provide = () => {} diff --git a/yarn.lock b/yarn.lock index a465ba1e1..8a9e8f81a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -810,6 +810,13 @@ source-map "^0.5.6" vue-template-es2015-compiler "^1.6.0" +"@vue/composition-api@^0.3.2": + version "0.3.2" + resolved "https://registry.yarnpkg.com/@vue/composition-api/-/composition-api-0.3.2.tgz#2d797028e489bf7812f08c7bb33ffd03ef23c617" + integrity sha512-fD4dn9cJX62QSP2TMFLXCOQOa+Bu2o7kWDjrU/FNLkNqPPcCKBLxCH/Lc+gNCRBKdEUGyI3arjAw7j0Yz1hnvw== + dependencies: + tslib "^1.9.3" + "@webassemblyjs/ast@1.4.3": version "1.4.3" resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.4.3.tgz#3b3f6fced944d8660273347533e6d4d315b5934a" @@ -9601,6 +9608,11 @@ trough@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/trough/-/trough-1.0.1.tgz#a9fd8b0394b0ae8fff82e0633a0a36ccad5b5f86" +tslib@^1.9.3: + version "1.10.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a" + integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ== + tty-browserify@0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6" From 8667d1925f9bab33c25be77b58b0c9677e97884e Mon Sep 17 00:00:00 2001 From: Jamie Stumme Date: Fri, 22 Nov 2019 06:51:01 -0600 Subject: [PATCH 04/17] Fix prettier on vscode workspace settings. --- .vscode/settings.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 2ed11fc0d..9cc43d98e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,4 @@ { - "javascript.validate.enable": false, - "flow.pathToFlow": "${workspaceFolder}/node_modules/.bin/flow" -} \ No newline at end of file + "javascript.validate.enable": false, + "flow.pathToFlow": "${workspaceFolder}/node_modules/.bin/flow" +} From eef7ae6f1824ffc0de749c10acb088c9047bfeb2 Mon Sep 17 00:00:00 2001 From: Jamie Stumme Date: Fri, 22 Nov 2019 06:52:00 -0600 Subject: [PATCH 05/17] More prettier changes --- .../component-with-inject-composition.vue | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/test/resources/components/component-with-inject-composition.vue b/test/resources/components/component-with-inject-composition.vue index fe1a48d6a..b2b40e827 100644 --- a/test/resources/components/component-with-inject-composition.vue +++ b/test/resources/components/component-with-inject-composition.vue @@ -5,18 +5,24 @@ From 07e5eef2c73f0f3e41d73c53f972f078372499c4 Mon Sep 17 00:00:00 2001 From: Jamie Stumme Date: Fri, 22 Nov 2019 07:13:52 -0600 Subject: [PATCH 06/17] Removed unused imports from injection composition vue file --- .../resources/components/component-with-inject-composition.vue | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/resources/components/component-with-inject-composition.vue b/test/resources/components/component-with-inject-composition.vue index b2b40e827..8b0deef96 100644 --- a/test/resources/components/component-with-inject-composition.vue +++ b/test/resources/components/component-with-inject-composition.vue @@ -7,9 +7,6 @@ diff --git a/test/specs/mounting-options/provide.spec.js b/test/specs/mounting-options/provide.spec.js index 97bb9d32c..8cb3f3627 100644 --- a/test/specs/mounting-options/provide.spec.js +++ b/test/specs/mounting-options/provide.spec.js @@ -1,8 +1,11 @@ import { config } from '~vue/test-utils' +import { createLocalVue } from '~vue/test-utils' import ComponentWithInject from '~resources/components/component-with-inject.vue' +import CompositionComponentWithInject from '~resources/components/component-with-inject-composition.vue' import { injectSupported } from '~resources/utils' import { describeWithShallowAndMount } from '~resources/utils' import { itDoNotRunIf, itSkipIf } from 'conditional-specs' +import VueCompositionApi from '@vue/composition-api' describeWithShallowAndMount('options.provide', mountingMethod => { let configProvideSave @@ -86,6 +89,21 @@ describeWithShallowAndMount('options.provide', mountingMethod => { } ) + itDoNotRunIf( + !injectSupported, + 'injects in a composition api component', + () => { + const localVue = createLocalVue() + localVue.use(VueCompositionApi) + const wrapper = mountingMethod(CompositionComponentWithInject, { + provide: { fromMount: '_' }, + localVue + }) + + expect(wrapper.html()).to.contain('_') + } + ) + it('config with function throws', () => { config.provide = () => {} diff --git a/yarn.lock b/yarn.lock index a465ba1e1..8a9e8f81a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -810,6 +810,13 @@ source-map "^0.5.6" vue-template-es2015-compiler "^1.6.0" +"@vue/composition-api@^0.3.2": + version "0.3.2" + resolved "https://registry.yarnpkg.com/@vue/composition-api/-/composition-api-0.3.2.tgz#2d797028e489bf7812f08c7bb33ffd03ef23c617" + integrity sha512-fD4dn9cJX62QSP2TMFLXCOQOa+Bu2o7kWDjrU/FNLkNqPPcCKBLxCH/Lc+gNCRBKdEUGyI3arjAw7j0Yz1hnvw== + dependencies: + tslib "^1.9.3" + "@webassemblyjs/ast@1.4.3": version "1.4.3" resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.4.3.tgz#3b3f6fced944d8660273347533e6d4d315b5934a" @@ -9601,6 +9608,11 @@ trough@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/trough/-/trough-1.0.1.tgz#a9fd8b0394b0ae8fff82e0633a0a36ccad5b5f86" +tslib@^1.9.3: + version "1.10.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a" + integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ== + tty-browserify@0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6" From f2d0524f894f3e7d04f3ebccfa265b31ee579b30 Mon Sep 17 00:00:00 2001 From: Jamie Stumme Date: Fri, 22 Nov 2019 06:51:01 -0600 Subject: [PATCH 12/17] Fix prettier on vscode workspace settings. --- .vscode/settings.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 2ed11fc0d..9cc43d98e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,4 @@ { - "javascript.validate.enable": false, - "flow.pathToFlow": "${workspaceFolder}/node_modules/.bin/flow" -} \ No newline at end of file + "javascript.validate.enable": false, + "flow.pathToFlow": "${workspaceFolder}/node_modules/.bin/flow" +} From dc5d0303f679547530e75f218582cafffcbf9d56 Mon Sep 17 00:00:00 2001 From: Jamie Stumme Date: Fri, 22 Nov 2019 06:52:00 -0600 Subject: [PATCH 13/17] More prettier changes --- .../component-with-inject-composition.vue | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/test/resources/components/component-with-inject-composition.vue b/test/resources/components/component-with-inject-composition.vue index fe1a48d6a..b2b40e827 100644 --- a/test/resources/components/component-with-inject-composition.vue +++ b/test/resources/components/component-with-inject-composition.vue @@ -5,18 +5,24 @@ From ba37406f875aeca2f59fd886e5886513fe6bc6e5 Mon Sep 17 00:00:00 2001 From: Jamie Stumme Date: Fri, 22 Nov 2019 07:13:52 -0600 Subject: [PATCH 14/17] Removed unused imports from injection composition vue file --- .../resources/components/component-with-inject-composition.vue | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/resources/components/component-with-inject-composition.vue b/test/resources/components/component-with-inject-composition.vue index b2b40e827..8b0deef96 100644 --- a/test/resources/components/component-with-inject-composition.vue +++ b/test/resources/components/component-with-inject-composition.vue @@ -7,9 +7,6 @@