(newValue)
| 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. |
nothing calls this directly
no test coverage detected