| 58 | } |
| 59 | |
| 60 | setDelegate(delegateSpec: ZoneSpec | null) { |
| 61 | const isNewDelegate = this._delegateSpec !== delegateSpec; |
| 62 | this._delegateSpec = delegateSpec; |
| 63 | this.propertyKeys && this.propertyKeys.forEach((key) => delete this.properties[key]); |
| 64 | this.propertyKeys = null; |
| 65 | if (delegateSpec && delegateSpec.properties) { |
| 66 | this.propertyKeys = Object.keys(delegateSpec.properties); |
| 67 | this.propertyKeys.forEach((k) => (this.properties[k] = delegateSpec.properties![k])); |
| 68 | } |
| 69 | // if a new delegateSpec was set, check if we need to trigger hasTask |
| 70 | if ( |
| 71 | isNewDelegate && |
| 72 | this.lastTaskState && |
| 73 | (this.lastTaskState.macroTask || this.lastTaskState.microTask) |
| 74 | ) { |
| 75 | this.isNeedToTriggerHasTask = true; |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | getDelegate() { |
| 80 | return this._delegateSpec; |