Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 6216dc0

Browse files
committed
chore(select): remove inherit, replace with expression locals
1 parent 761b2ed commit 6216dc0

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/widget/select.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ var selectDirective = ['$formFactory', '$compile', '$parse',
243243
widget.$apply(function() {
244244
var optionGroup,
245245
collection = valuesFn(modelScope) || [],
246-
tempScope = inherit(modelScope),
246+
locals = {},
247247
key, value, optionElement, index, groupIndex, length, groupLength;
248248

249249
if (multiple) {
@@ -257,9 +257,9 @@ var selectDirective = ['$formFactory', '$compile', '$parse',
257257
for(index = 1, length = optionGroup.length; index < length; index++) {
258258
if ((optionElement = optionGroup[index].element)[0].selected) {
259259
key = optionElement.val();
260-
if (keyName) tempScope[keyName] = key;
261-
tempScope[valueName] = collection[key];
262-
value.push(valueFn(tempScope));
260+
if (keyName) locals[keyName] = key;
261+
locals[valueName] = collection[key];
262+
value.push(valueFn(modelScope, locals));
263263
}
264264
}
265265
}
@@ -270,9 +270,9 @@ var selectDirective = ['$formFactory', '$compile', '$parse',
270270
} else if (key == ''){
271271
value = null;
272272
} else {
273-
tempScope[valueName] = collection[key];
274-
if (keyName) tempScope[keyName] = key;
275-
value = valueFn(tempScope);
273+
locals[valueName] = collection[key];
274+
if (keyName) locals[keyName] = key;
275+
value = valueFn(modelScope, locals);
276276
}
277277
}
278278
if (isDefined(value) && modelScope.$viewVal !== value) {
@@ -296,7 +296,7 @@ var selectDirective = ['$formFactory', '$compile', '$parse',
296296
keys = keyName ? sortedKeys(values) : values,
297297
groupLength, length,
298298
groupIndex, index,
299-
optionScope = inherit(modelScope),
299+
locals = {},
300300
selected,
301301
selectedSet = false, // nothing is selected yet
302302
lastElement,
@@ -312,21 +312,21 @@ var selectDirective = ['$formFactory', '$compile', '$parse',
312312

313313
// We now build up the list of options we need (we merge later)
314314
for (index = 0; length = keys.length, index < length; index++) {
315-
optionScope[valueName] = values[keyName ? optionScope[keyName]=keys[index]:index];
316-
optionGroupName = groupByFn(optionScope) || '';
315+
locals[valueName] = values[keyName ? locals[keyName]=keys[index]:index];
316+
optionGroupName = groupByFn(modelScope, locals) || '';
317317
if (!(optionGroup = optionGroups[optionGroupName])) {
318318
optionGroup = optionGroups[optionGroupName] = [];
319319
optionGroupNames.push(optionGroupName);
320320
}
321321
if (multiple) {
322-
selected = selectedSet.remove(valueFn(optionScope)) != undefined;
322+
selected = selectedSet.remove(valueFn(modelScope, locals)) != undefined;
323323
} else {
324-
selected = modelValue === valueFn(optionScope);
324+
selected = modelValue === valueFn(modelScope, locals);
325325
selectedSet = selectedSet || selected; // see if at least one item is selected
326326
}
327327
optionGroup.push({
328328
id: keyName ? keys[index] : index, // either the index into array or key from object
329-
label: displayFn(optionScope) || '', // what will be seen by the user
329+
label: displayFn(modelScope, locals) || '', // what will be seen by the user
330330
selected: selected // determine if we should be selected
331331
});
332332
}

0 commit comments

Comments
 (0)