Skip to content

Commit fbc41b9

Browse files
Enhancement to support issue #268
1 parent 9610d5f commit fbc41b9

File tree

5 files changed

+49
-10
lines changed

5 files changed

+49
-10
lines changed

dist/vuedraggable.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
111111
move: {
112112
type: Function,
113113
default: null
114+
},
115+
componentData: {
116+
type: Object,
117+
required: false,
118+
default: null
114119
}
115120
};
116121

@@ -141,7 +146,18 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
141146
children = slots ? [].concat(_toConsumableArray(slots), _toConsumableArray(footer)) : [].concat(_toConsumableArray(footer));
142147
}
143148
var attributes = null;
144-
attributes = buildAttribute(attributes, 'attrs', this.$attrs);
149+
var update = function update(name, value) {
150+
attributes = buildAttribute(attributes, name, value);
151+
};
152+
update('attrs', this.$attrs);
153+
if (this.componentData) {
154+
var _componentData = this.componentData,
155+
on = _componentData.on,
156+
_props = _componentData.props;
157+
158+
update('on', on);
159+
update('props', _props);
160+
}
145161
return h(this.element, attributes, children);
146162
},
147163
mounted: function mounted() {

dist/vuedraggable.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/Component3.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<body>
1616

1717
<div id="app">
18-
<draggable element="el-collapse" :list="list" :options="sortOptions" :component-data="componentData">
18+
<draggable element="el-collapse" :list="list" :options="sortOptions" :component-data="getComponentData()">
1919
<el-collapse-item v-for="(item) in list" :title="item.title" :name="item.name" :key="item.name">
2020
<div>{{item.description}}</div>
2121
</el-collapse-item>

examples/script/component3.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@ var App = new Vue({
66
methods: {
77
handleChange() {
88
console.log('times are changing');
9+
},
10+
inputChanged(value) {
11+
this.activeNames = value;
12+
},
13+
getComponentData() {
14+
return {
15+
on: {
16+
change: this.handleChange,
17+
input: this.inputChanged
18+
},
19+
props: {
20+
value: this.activeNames
21+
}
22+
};
923
}
1024
},
1125
data() {
@@ -16,14 +30,12 @@ var App = new Vue({
1630
group: 'sample',
1731
animation: 150,
1832
},
19-
componentData:{
20-
on:{
33+
componentData: {
34+
on: {
2135
change: this.handleChange,
22-
input(value){
23-
this.activeNames = value;
24-
}
36+
input: this.inputChanged
2537
},
26-
props:{
38+
props: {
2739
value: this.activeNames
2840
}
2941
},

src/vuedraggable.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@
8585
move: {
8686
type: Function,
8787
default: null
88+
},
89+
componentData: {
90+
type: Object,
91+
required: false,
92+
default: null
8893
}
8994
}
9095

@@ -115,7 +120,13 @@
115120
children = slots ? [...slots, ...footer] : [...footer]
116121
}
117122
var attributes = null;
118-
attributes = buildAttribute(attributes, 'attrs', this.$attrs);
123+
const update = (name, value) => { attributes = buildAttribute(attributes, name, value); };
124+
update('attrs', this.$attrs);
125+
if (this.componentData) {
126+
const { on, props } = this.componentData;
127+
update('on', on);
128+
update('props', props);
129+
}
119130
return h(this.element, attributes, children);
120131
},
121132

0 commit comments

Comments
 (0)