Skip to content

Commit

Permalink
fix: component keys
Browse files Browse the repository at this point in the history
  • Loading branch information
wxsms committed Aug 24, 2021
1 parent bbd81c7 commit d86376f
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 44 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"dist:test": "rollup -c rollup/rollup.test.js",
"build": "node build/build-docs.js && node build/build-dist-config.js",
"test": "cross-env NODE_ENV=test karma start test/karma.conf.js --single-run",
"lint": "eslint --ext .js,.vue src test/specs",
"lint": "eslint --ext .js,.vue src test",
"lint:fix": "npm run lint -- --fix",
"coveralls": "cat test/coverage/lcov.info | ./node_modules/.bin/coveralls"
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/carousel/Carousel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
:key="index"
:class="{ active: index === activeIndex }"
@click="select(index)"
></li>
/>
</ol>
</slot>
<div class="carousel-inner" role="listbox">
Expand Down
4 changes: 2 additions & 2 deletions src/components/datepicker/DateView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
</tr>
</thead>
<tbody>
<tr v-for="(row, index) in monthDayRows" :key="index">
<tr v-for="(row, i) in monthDayRows" :key="i">
<td
v-if="weekNumbers"
class="text-center"
Expand All @@ -60,7 +60,7 @@
getWeekNumber(row[weekStartsWith])
}}</small>
</td>
<td v-for="(date, _index) in row" :key="_index">
<td v-for="(date, j) in row" :key="`${i}_${j}`">
<btn
block
size="sm"
Expand Down
7 changes: 6 additions & 1 deletion src/components/datepicker/MonthView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@
</thead>
<tbody>
<tr v-for="(row, i) in rows" :key="i">
<td v-for="(month, j) in row" :key="j" colspan="2" width="33.333333%">
<td
v-for="(month, j) in row"
:key="`${i}_${j}`"
colspan="2"
width="33.333333%"
>
<btn
block
size="sm"
Expand Down
4 changes: 2 additions & 2 deletions src/components/datepicker/YearView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
</tr>
</thead>
<tbody>
<tr v-for="(row, index) in rows" :key="index">
<td v-for="(year, _index) in row" :key="_index" width="20%">
<tr v-for="(row, i) in rows" :key="i">
<td v-for="(year, j) in row" :key="`${i}_${j}`" width="20%">
<btn
block
size="sm"
Expand Down
6 changes: 3 additions & 3 deletions src/components/select/MultiSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@
@keydown.prevent.stop.enter="selectOption"
/>
</li>
<template v-for="(item, index) in groupedOptions">
<template v-for="(item, i) in groupedOptions">
<li
v-if="item.$group"
:key="index"
:key="i"
class="dropdown-header"
v-text="item.$group"
></li>
<template v-for="(_item, j) in item.options">
<li
:key="j"
:key="`${i}_${j}`"
:class="itemClasses(_item)"
style="outline: 0"
@keydown.prevent.stop.down="goNextOption"
Expand Down
8 changes: 4 additions & 4 deletions src/components/tabs/Tabs.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<template>
<section>
<ul :class="navClasses" role="tablist">
<template v-for="(tab, index) in groupedTabs">
<template v-for="(tab, i) in groupedTabs">
<dropdown
v-if="tab.tabs"
v-show="!tab.hidden"
:key="index"
:key="i"
role="presentation"
tag="li"
:class="getTabClasses(tab)"
Expand All @@ -17,7 +17,7 @@
<li
v-for="(subTab, j) in tab.tabs"
v-show="!subTab.hidden"
:key="j"
:key="`${i}_${j}`"
:class="getTabClasses(subTab, true)"
>
<a href="#" @click.prevent="select(tabs.indexOf(subTab))">{{
Expand All @@ -29,7 +29,7 @@
<li
v-else
v-show="!tab.hidden"
:key="index"
:key="i"
role="presentation"
:class="getTabClasses(tab)"
>
Expand Down
9 changes: 0 additions & 9 deletions test/.eslintrc

This file was deleted.

22 changes: 11 additions & 11 deletions test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ module.exports = function (config) {
// 2. add it to the `browsers` array below.
browsers: ['ChromeHeadlessDesktop'],
customLaunchers: {
'ChromeHeadlessDesktop': {
ChromeHeadlessDesktop: {
base: 'ChromeHeadless',
flags: ['--window-size=1920,1080', '--no-sandbox']
}
flags: ['--window-size=1920,1080', '--no-sandbox'],
},
},
// browsers: ['Chrome'],
frameworks: ['mocha', 'sinon-chai'],
Expand All @@ -28,10 +28,10 @@ module.exports = function (config) {
* because the preprocessor will use its own.
*/
{ pattern: './index.js', watched: false },
'../node_modules/bootstrap/dist/css/bootstrap.min.css'
'../node_modules/bootstrap/dist/css/bootstrap.min.css',
],
preprocessors: {
'./index.js': ['rollup']
'./index.js': ['rollup'],
},
rollupPreprocessor: require('../rollup/rollup.test'),
singleRun: true,
Expand All @@ -42,15 +42,15 @@ module.exports = function (config) {
skipFilesWithNoCoverage: true,
'report-config': {
lcovonly: {
subdir: '.'
subdir: '.',
},
html: {
subdir: './html'
}
}
subdir: './html',
},
},
},
client: {
useIframe: false // Page scroll not working without this!!!
}
useIframe: false, // Page scroll not working without this!!!
},
})
}
4 changes: 2 additions & 2 deletions test/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as uiv from '../src/install'

Vue.config.productionTip = false
// simulate router-link
Vue.component('router-link', {
template: '<a href="#router-link"><slot></slot></a>'
Vue.component('RouterLink', {
template: '<a href="#router-link"><slot></slot></a>',
})
Vue.use(uiv)
14 changes: 6 additions & 8 deletions test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const keyCodes = {
left: 37,
right: 39,
down: 40,
'delete': [8, 46]
delete: [8, 46],
}

export const triggerEvent = (elm, name, evtProps = {}, ...opts) => {
Expand All @@ -33,9 +33,7 @@ export const triggerEvent = (elm, name, evtProps = {}, ...opts) => {
evt[k] = evtProps[k]
}
}
elm.dispatchEvent
? elm.dispatchEvent(evt)
: elm.fireEvent('on' + name, evt)
elm.dispatchEvent ? elm.dispatchEvent(evt) : elm.fireEvent('on' + name, evt)
return elm
}

Expand All @@ -55,7 +53,7 @@ export const triggerKey = (el, key, type = 'down') => {
}

export const sleep = (time) => {
return new Promise(resolve => {
return new Promise((resolve) => {
setTimeout(resolve, time)
})
}
Expand All @@ -64,14 +62,14 @@ export const createVm = (template, _data, _options) => {
$('<div id="app"><div id="mount"></div></div>').appendTo('body')
const res = Vue.compile(template)
return new Vue({
data () {
data() {
return {
..._data
..._data,
}
},
..._options,
render: res.render,
staticRenderFns: res.staticRenderFns
staticRenderFns: res.staticRenderFns,
}).$mount('#mount')
}

Expand Down

0 comments on commit d86376f

Please sign in to comment.