Skip to content

Commit

Permalink
fix: update refs inside v-for to work for @vue/compat
Browse files Browse the repository at this point in the history
  • Loading branch information
xanf committed Oct 24, 2022
1 parent 411e0e9 commit ae4bac8
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 35 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@
"@nuxtjs/robots": "^2.5.0",
"@nuxtjs/sitemap": "^2.4.0",
"@testing-library/jest-dom": "^5.12.0",
"@vue/compat": "^3.2.24",
"@vue/compiler-dom": "^3.2.24",
"@vue/compat": "^3.2.40",
"@vue/compiler-dom": "^3.2.40",
"@vue/test-utils": "^1.3.0",
"@vue/test-utils-vue3": "npm:@vue/test-utils@2.0.0-rc.18",
"@vue/test-utils-vue3": "npm:@vue/test-utils@2.1.0",
"autoprefixer": "^10.4.0",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.1.0",
Expand Down
4 changes: 2 additions & 2 deletions src/components/table/helpers/mixin-tbody-row.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Vue } from '../../../vue'
import { Vue, REF_FOR_KEY } from '../../../vue'
import {
EVENT_NAME_ROW_CLICKED,
EVENT_NAME_ROW_HOVERED,
Expand Down Expand Up @@ -271,7 +271,7 @@ export const tbodyRowMixin = Vue.extend({
},
key: `__b-table-row-${rowKey}__`,
ref: 'item-rows',
refInFor: true
[REF_FOR_KEY]: true
},
$tds
)
Expand Down
4 changes: 2 additions & 2 deletions src/components/tabs/tabs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { COMPONENT_UID_KEY, Vue } from '../../vue'
import { COMPONENT_UID_KEY, REF_FOR_KEY, Vue } from '../../vue'
import { NAME_TABS, NAME_TAB_BUTTON_HELPER } from '../../constants/components'
import { IS_BROWSER } from '../../constants/env'
import {
Expand Down Expand Up @@ -598,7 +598,7 @@ export const BTabs = /*#__PURE__*/ Vue.extend({
key: $tab[COMPONENT_UID_KEY] || index,
ref: 'buttons',
// Needed to make `this.$refs.buttons` an array
refInFor: true
[REF_FOR_KEY]: true
})
})

Expand Down
4 changes: 2 additions & 2 deletions src/components/time/time.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// BTime control (not form input control)
import { Vue } from '../../vue'
import { Vue, REF_FOR_KEY } from '../../vue'
import { NAME_TIME } from '../../constants/components'
import { EVENT_NAME_CONTEXT } from '../../constants/events'
import { CODE_LEFT, CODE_RIGHT } from '../../constants/key-codes'
Expand Down Expand Up @@ -441,7 +441,7 @@ export const BTime = /*#__PURE__*/ Vue.extend({
},
key,
ref: 'spinners',
refInFor: true
[REF_FOR_KEY]: true
})
}

Expand Down
2 changes: 2 additions & 0 deletions src/vue.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const COMPONENT_UID_KEY = '_uid'

const isVue3 = Vue.version.startsWith('3')

export const REF_FOR_KEY = isVue3 ? 'ref_for' : 'refInFor'

const ALLOWED_FIELDS_IN_DATA = [
'class',
'staticClass',
Expand Down
1 change: 0 additions & 1 deletion tests/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ if (useVue3) {
OPTIONS_DATA_MERGE: 'suppress-warning',
OPTIONS_DESTROYED: 'suppress-warning',
RENDER_FUNCTION: 'suppress-warning',
V_FOR_REF: 'suppress-warning',
WATCH_ARRAY: 'suppress-warning'
})

Expand Down
59 changes: 34 additions & 25 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -617,11 +617,16 @@
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.16.12.tgz#9474794f9a650cf5e2f892444227f98e28cdf8b6"
integrity sha512-VfaV15po8RiZssrkPweyvbGVSe4x2y+aciFCgn0n0/SJMR22cwofRV1mtnJQYcSB1wUTaA/X1LnA3es66MCO5A==

"@babel/parser@^7.15.0", "@babel/parser@^7.16.0":
"@babel/parser@^7.16.0":
version "7.16.2"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.16.2.tgz#3723cd5c8d8773eef96ce57ea1d9b7faaccd12ac"
integrity sha512-RUVpT0G2h6rOZwqLDTrKk7ksNv7YpAilTnYe1/Q+eDjxEceRMKVWbCsX7t8h6C1qCFi/1Y8WZjcEPBAFG27GPw==

"@babel/parser@^7.16.4":
version "7.19.3"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.19.3.tgz#8dd36d17c53ff347f9e55c328710321b49479a9a"
integrity sha512-pJ9xOlNWHiy9+FuFP09DEAFbAn4JskgRsVcc169w2xRBC3FRGuQEwjeIMMND9L2zc0iEhO/tGv4Zq+km+hxNpQ==

"@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@^7.13.12":
version "7.13.12"
resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/-/plugin-bugfix-v8-spread-parameters-in-optional-chaining-7.13.12.tgz#a3484d84d0b549f3fc916b99ee4783f26fabad2a"
Expand Down Expand Up @@ -2754,28 +2759,32 @@
"@vue/babel-plugin-transform-vue-jsx" "^1.2.1"
camelcase "^5.0.0"

"@vue/compat@^3.2.24":
version "3.2.24"
resolved "https://registry.yarnpkg.com/@vue/compat/-/compat-3.2.24.tgz#6b10efb2773ccc8a59e625b4082bdc7cf2012549"
integrity sha512-fhnNc+SJ/hbhKZexVHVK+vZ0VstHm32VXgFEoiV1WWYNGRFJB5X7jbO/1a09IQgURiHwP0Km9jQQzN7/7sSbag==
"@vue/compat@^3.2.40":
version "3.2.40"
resolved "https://registry.yarnpkg.com/@vue/compat/-/compat-3.2.40.tgz#5ffa8999121daaff585eea1dce0352580e562bfd"
integrity sha512-PZl6tsjWC2KENXfeJ+hI+wbvN7lgLBVyf6fgE1bybxUtfDcw/Eon3RrapEHnp86zuZU++ThGqq1U03ZacznR0g==
dependencies:
"@babel/parser" "^7.16.4"
estree-walker "^2.0.2"
source-map "^0.6.1"

"@vue/compiler-core@3.2.24":
version "3.2.24"
resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.2.24.tgz#cadcda0e026e7f1cd453ce87160be51a5f313fe0"
integrity sha512-A0SxB2HAggKzP57LDin5gfgWOTwFyGCtQ5MTMNBADnfQYALWnYuC8kMI0DhRSplGTWRvn9Z2DAnG8f35BnojuA==
"@vue/compiler-core@3.2.40":
version "3.2.40"
resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.2.40.tgz#c785501f09536748121e937fb87605bbb1ada8e5"
integrity sha512-2Dc3Stk0J/VyQ4OUr2yEC53kU28614lZS+bnrCbFSAIftBJ40g/2yQzf4mPBiFuqguMB7hyHaujdgZAQ67kZYA==
dependencies:
"@babel/parser" "^7.15.0"
"@vue/shared" "3.2.24"
"@babel/parser" "^7.16.4"
"@vue/shared" "3.2.40"
estree-walker "^2.0.2"
source-map "^0.6.1"

"@vue/compiler-dom@^3.2.24":
version "3.2.24"
resolved "https://registry.yarnpkg.com/@vue/compiler-dom/-/compiler-dom-3.2.24.tgz#32235cb444660245be5cc58f4beb76747400505c"
integrity sha512-KQEm8r0JFsrNNIfbD28pcwMvHpcJcwjVR1XWFcD0yyQ8eREd7IXhT7J6j7iNCSE/TIo78NOvkwbyX+lnIm836w==
"@vue/compiler-dom@^3.2.40":
version "3.2.40"
resolved "https://registry.yarnpkg.com/@vue/compiler-dom/-/compiler-dom-3.2.40.tgz#c225418773774db536174d30d3f25ba42a33e7e4"
integrity sha512-OZCNyYVC2LQJy4H7h0o28rtk+4v+HMQygRTpmibGoG9wZyomQiS5otU7qo3Wlq5UfHDw2RFwxb9BJgKjVpjrQw==
dependencies:
"@vue/compiler-core" "3.2.24"
"@vue/shared" "3.2.24"
"@vue/compiler-core" "3.2.40"
"@vue/shared" "3.2.40"

"@vue/component-compiler-utils@^3.1.0":
version "3.2.0"
Expand All @@ -2793,15 +2802,15 @@
optionalDependencies:
prettier "^1.18.2"

"@vue/shared@3.2.24":
version "3.2.24"
resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.2.24.tgz#d74615e856013b17fb60b19b09d712729ad5e090"
integrity sha512-BUgRiZCkCrqDps5aQ9av05xcge3rn092ztKIh17tHkeEFgP4zfXMQWBA2zfdoCdCEdBL26xtOv+FZYiOp9RUDA==
"@vue/shared@3.2.40":
version "3.2.40"
resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.2.40.tgz#e57799da2a930b975321981fcee3d1e90ed257ae"
integrity sha512-0PLQ6RUtZM0vO3teRfzGi4ltLUO5aO+kLgwh4Um3THSR03rpQWLTuRCkuO5A41ITzwdWeKdPHtSARuPkoo5pCQ==

"@vue/test-utils-vue3@npm:@vue/test-utils@2.0.0-rc.18":
version "2.0.0-rc.18"
resolved "https://registry.yarnpkg.com/@vue/test-utils/-/test-utils-2.0.0-rc.18.tgz#ff22b252424fe72e5462cbb3a8e7405cef11ffb6"
integrity sha512-aifolXjVdsogjaLmDoZ0FU8vN+R67aWmg9OuVeED4w5Ij5GFQLrlhM19uhWe/r5xXUL4fXMk3pX5wW6FJP1NcQ==
"@vue/test-utils-vue3@npm:@vue/test-utils@2.1.0":
version "2.1.0"
resolved "https://registry.yarnpkg.com/@vue/test-utils/-/test-utils-2.1.0.tgz#c2f646aa2d6ac779f79a83f18c5b82fc40952bfd"
integrity sha512-U4AxAD/tKJ3ajxYew1gkfEotpr96DE/gLXpbl+nPbsNRqGBfQZZA7YhwGoQNDPgon56v+IGZDrYq7pe3GDl9aw==

"@vue/test-utils@^1.3.0":
version "1.3.0"
Expand Down

0 comments on commit ae4bac8

Please sign in to comment.