Skip to content

Commit 40068af

Browse files
committed
Fixes normalization to use $set
1 parent 0c4e479 commit 40068af

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Yet another Vue treeview component.",
44
"author": "Gregg Rapoza <[email protected]>",
55
"license": "MIT",
6-
"version": "0.3.4",
6+
"version": "0.3.5",
77
"browser": "index.js",
88
"repository": {
99
"url": "https://github.com/grapoza/vue-tree",

src/components/TreeViewNode.vue

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,15 @@
153153
154154
// Set expected properties if not provided
155155
if (!Array.isArray(this.model.children)) {
156-
this.model.children = [];
156+
this.$set(this.model, 'children', []);
157157
}
158158
159159
// Set basic node options
160160
if (typeof this.model.expandable !== 'boolean') {
161-
this.model.expandable = true;
161+
this.$set(this.model, 'expandable', true);
162162
}
163163
if (typeof this.model.selectable !== 'boolean') {
164-
this.model.selectable = false;
164+
this.$set(this.model, 'selectable', false);
165165
}
166166
167167
this.$_treeViewNode_normalizeNodeInputData();
@@ -177,22 +177,22 @@
177177
// For nodes that are inputs, they must specify at least a type.
178178
// Only a subset of types are accepted.
179179
if (input === null || typeof input !== 'object' || !['checkbox', 'radio'].includes(input.type)) {
180-
this.model.input = null;
180+
this.$set(this.model, 'input', null);
181181
}
182182
else {
183183
if (typeof input.name !== 'string' || input.name.trim().length === 0) {
184-
input.name = null;
184+
this.$set(input, 'name', null);
185185
}
186186
187187
if (input.type === 'radio') {
188188
if (typeof input.name !== 'string' || input.name.trim().length === 0) {
189-
input.name = 'unspecifiedRadioName';
189+
this.$set(input, 'name', 'unspecifiedRadioName');
190190
}
191191
if (typeof input.value !== 'string' || input.value.trim().length === 0) {
192-
input.value = this.model.label.replace(/[\s&<>"'\/]/g, '');
192+
this.$set(input, 'value', this.model.label.replace(/[\s&<>"'\/]/g, ''));
193193
}
194194
if (!this.radioGroupValues.hasOwnProperty(input.name)) {
195-
this.radioGroupValues[input.name] = '';
195+
this.$set(this.radioGroupValues, input.name, '');
196196
}
197197
}
198198
}
@@ -202,31 +202,31 @@
202202
*/
203203
$_treeViewNode_normalizeNodeStateData() {
204204
if (this.model.state === null || typeof this.model.state !== 'object') {
205-
this.model.state = {};
205+
this.$set(this.model, 'state', {});
206206
}
207207
208208
let state = this.model.state;
209209
210210
if (typeof state.expanded !== 'boolean') {
211-
state.expanded = false;
211+
this.$set(state, 'expanded', false);
212212
}
213213
if (typeof state.selected !== 'boolean') {
214-
state.selected = false;
214+
this.$set(state, 'selected', false);
215215
}
216216
217217
if (this.model.input) {
218218
if (state.input === null || typeof state.input !== 'object') {
219-
state.input = {};
219+
this.$set(state, 'input', {});
220220
}
221221
222222
if (state.input.disabled === null || typeof state.input.disabled !== 'boolean') {
223-
state.input.disabled = false;
223+
this.$set(state.input, 'disabled', false);
224224
}
225225
226226
if (this.model.input.type === 'checkbox') {
227227
228228
if (typeof state.input.value !== 'boolean') {
229-
state.input.value = false;
229+
this.$set(state.input, 'value', false);
230230
}
231231
}
232232
}

0 commit comments

Comments
 (0)