Skip to content

Commit

Permalink
Merge pull request #632 from wenzhixin/feature/data-watch
Browse files Browse the repository at this point in the history
Fix data watch deep cause by selected bug
  • Loading branch information
wenzhixin authored Jul 5, 2024
2 parents cd087a2 + 7e4ce3b commit b7b41b0
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 25 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "multiple-select",
"main": "dist/multiple-select.min.js",
"module": "dist/multiple-select-es.min.js",
"version": "2.0.6",
"version": "2.0.8",
"type": "module",
"title": "Multiple Select",
"description": "Multiple select is a jQuery plugin to select multiple elements with checkboxes :).",
Expand Down
2 changes: 1 addition & 1 deletion src/MultipleSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class MultipleSelect {
value: it
}
}
return it
return { ...it }
})
} else if (typeof this.options.data === 'object') {
for (const [value, text] of Object.entries(this.options.data)) {
Expand Down
2 changes: 1 addition & 1 deletion src/vue/MultipleSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export default {
single: !this.multiple,
width: this.width,
size: this.size,
data: deepCopy(this.data)
data: this.data
}
if (!this._hasInit) {
Expand Down
18 changes: 9 additions & 9 deletions vue-examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore"
},
"dependencies": {
"highlight.js": "^11.8.0",
"jquery": "^3.7.0",
"multiple-select": "^1.7.0",
"vue": "^3.4.15",
"vue-router": "^4.0.0"
"highlight.js": "^11.9.0",
"jquery": "^3.7.1",
"multiple-select": "^2.0.7",
"vue": "^3.4.31",
"vue-router": "^4.4.0"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.0.4",
"autoprefixer": "^10.4.18",
"@vitejs/plugin-vue": "^5.0.5",
"autoprefixer": "^10.4.19",
"eslint": "^8.49.0",
"eslint-plugin-vue": "^9.17.0",
"vite": "^5.1.5"
"eslint-plugin-vue": "^9.27.0",
"vite": "^5.3.3"
},
"eslintConfig": {
"root": true,
Expand Down
7 changes: 5 additions & 2 deletions vue-examples/src/examples/Data.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

<div class="col-sm-10">
<MultipleSelect
v-model="basic"
multiple
:data="basicData"
/>
Expand Down Expand Up @@ -59,6 +60,7 @@

<div class="col-sm-10">
<MultipleSelect
v-model="groups"
multiple
:data="groupData"
/>
Expand All @@ -71,6 +73,7 @@
export default {
data () {
return {
basic: [],
basicData: [
{
text: 'January',
Expand Down Expand Up @@ -141,15 +144,15 @@ export default {
numberData: [
1, 2, 3
],
groups: [1],
groupData: [
{
type: 'optgroup',
label: 'Group 1',
children: [
{
text: 'January',
value: 1,
selected: true
value: 1
},
{
text: 'February',
Expand Down
7 changes: 4 additions & 3 deletions vue-examples/src/plugins/select.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import 'multiple-select/dist/multiple-select.min.css'
import 'multiple-select/src/multiple-select.scss'

import './jquery'
import $ from 'jquery'
import 'multiple-select/src/multiple-select'
import 'multiple-select/dist/multiple-select-locale-all'
import 'multiple-select/src/multiple-select.js'
import 'multiple-select/src/locale/multiple-select-en-US'
import 'multiple-select/src/locale/multiple-select-zh-CN'

$.extend($.fn.multipleSelect.defaults, $.fn.multipleSelect.locales['en-US'])
3 changes: 3 additions & 0 deletions vue-examples/src/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ const raws = import.meta.glob('./examples/*.vue', { as: 'raw' })
const components = []

for (const path in modules) {
if (!modules[path]) {
continue
}
const name = (/examples\/(.*).vue/.exec(path))[1]

components.push({
Expand Down
16 changes: 8 additions & 8 deletions vue-examples/src/views/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ const updateAds = () => {
}, 500)
}
const updateHighlight = () => {
nextTick(() => {
document.querySelectorAll('pre code').forEach(el => {
hljs.highlightElement(el)
})
})
}
watch(props.current, () => {
updateAds()
})
Expand All @@ -108,14 +116,6 @@ onMounted(() => {
hljs.registerLanguage('xml', xml)
updateHighlight()
})
const updateHighlight = () => {
nextTick(() => {
document.querySelectorAll('pre code').forEach(el => {
hljs.highlightElement(el)
})
})
}
</script>

<style scoped>
Expand Down

0 comments on commit b7b41b0

Please sign in to comment.