MCPcopy Create free account
hub / github.com/aurelia/binding / setValue

Method setValue

src/select-value-observer.js:18–45  ·  view source on GitHub ↗
(newValue)

Source from the content-addressed store, hash-verified

16 }
17
18 setValue(newValue) {
19 if (newValue !== null && newValue !== undefined && this.element.multiple && !Array.isArray(newValue)) {
20 throw new Error('Only null or Array instances can be bound to a multi-select.');
21 }
22 if (this.value === newValue) {
23 return;
24 }
25 // unsubscribe from old array.
26 if (this.arrayObserver) {
27 this.arrayObserver.unsubscribe(selectArrayContext, this);
28 this.arrayObserver = null;
29 }
30 // subscribe to new array.
31 if (Array.isArray(newValue)) {
32 this.arrayObserver = this.observerLocator.getArrayObserver(newValue);
33 this.arrayObserver.subscribe(selectArrayContext, this);
34 }
35 // assign and sync element.
36 this.oldValue = this.value;
37 this.value = newValue;
38 this.synchronizeOptions();
39 this.notify();
40 // queue up an initial sync after the bindings have been evaluated.
41 if (!this.initialSync) {
42 this.initialSync = true;
43 this.observerLocator.taskQueue.queueMicroTask(this);
44 }
45 }
46
47 call(context, splices) {
48 // called by task queue and array observer.

Callers

nothing calls this directly

Calls 5

synchronizeOptionsMethod · 0.95
notifyMethod · 0.95
getArrayObserverMethod · 0.80
unsubscribeMethod · 0.65
subscribeMethod · 0.65

Tested by

no test coverage detected