|
| 1 | +// deno-lint-ignore-file no-unused-vars |
| 2 | +class Event { |
| 3 | + constructor(type, eventInitDict = { __proto__: null }) { |
| 4 | + // @ts-ignore - this is a hack to make the URL object work |
| 5 | + this.SymbolToStringTag = "Event"; |
| 6 | + // @ts-ignore - this is a hack to make the URL object work |
| 7 | + this.canceledFlag = false; |
| 8 | + // @ts-ignore - this is a hack to make the URL object work |
| 9 | + this.stopPropagationFlag = false; |
| 10 | + // @ts-ignore - this is a hack to make the URL object work |
| 11 | + this._stopImmediatePropagationFlag = false; |
| 12 | + // @ts-ignore - this is a hack to make the URL object work |
| 13 | + this._inPassiveListener = false; |
| 14 | + // @ts-ignore - this is a hack to make the URL object work |
| 15 | + this.dispatched = false; |
| 16 | + // @ts-ignore - this is a hack to make the URL object work |
| 17 | + this.isTrusted = false; |
| 18 | + // @ts-ignore - this is a hack to make the URL object work |
| 19 | + this.path = []; |
| 20 | + |
| 21 | + // @ts-ignore - this is a hack to make the URL object work |
| 22 | + this.attributes = { |
| 23 | + type, |
| 24 | + // @ts-ignore - this is a hack to make the URL object work |
| 25 | + bubbles: !!eventInitDict.bubbles, |
| 26 | + // @ts-ignore - this is a hack to make the URL object work |
| 27 | + cancelable: !!eventInitDict.cancelable, |
| 28 | + // @ts-ignore - this is a hack to make the URL object work |
| 29 | + composed: !!eventInitDict.composed, |
| 30 | + currentTarget: null, |
| 31 | + eventPhase: Event.NONE, |
| 32 | + target: null, |
| 33 | + timeStamp: 0, |
| 34 | + }; |
| 35 | + } |
| 36 | + |
| 37 | + get type() { |
| 38 | + // @ts-ignore - this is a hack to make the URL object work |
| 39 | + return this.attributes.type; |
| 40 | + } |
| 41 | + |
| 42 | + // TODO: Null is not returned |
| 43 | + get target() { |
| 44 | + // @ts-ignore - this is a hack to make the URL object work |
| 45 | + return this.attributes.target; |
| 46 | + } |
| 47 | + |
| 48 | + get srcElement() { |
| 49 | + return null; |
| 50 | + } |
| 51 | + |
| 52 | + set srcElement(_) { |
| 53 | + // this member is deprecated |
| 54 | + } |
| 55 | + |
| 56 | + // TODO: Null is not returned |
| 57 | + get currentTarget() { |
| 58 | + // @ts-ignore - this is a hack to make the URL object work |
| 59 | + return this.attributes.currentTarget; |
| 60 | + } |
| 61 | + |
| 62 | + get NONE() { |
| 63 | + return Event.NONE; |
| 64 | + } |
| 65 | + |
| 66 | + get CAPTURING_PHASE() { |
| 67 | + return Event.CAPTURING_PHASE; |
| 68 | + } |
| 69 | + |
| 70 | + get AT_TARGET() { |
| 71 | + return Event.AT_TARGET; |
| 72 | + } |
| 73 | + |
| 74 | + get BUBBLING_PHASE() { |
| 75 | + return Event.BUBBLING_PHASE; |
| 76 | + } |
| 77 | + |
| 78 | + static get NONE() { |
| 79 | + return 0; |
| 80 | + } |
| 81 | + |
| 82 | + static get CAPTURING_PHASE() { |
| 83 | + return 1; |
| 84 | + } |
| 85 | + |
| 86 | + static get AT_TARGET() { |
| 87 | + return 2; |
| 88 | + } |
| 89 | + |
| 90 | + static get BUBBLING_PHASE() { |
| 91 | + return 3; |
| 92 | + } |
| 93 | + |
| 94 | + get eventPhase() { |
| 95 | + // @ts-ignore - this is a hack to make the URL object work |
| 96 | + return this.attributes.eventPhase; |
| 97 | + } |
| 98 | + |
| 99 | + stopPropagation() { |
| 100 | + // @ts-ignore - this is a hack to make the URL object work |
| 101 | + this.stopPropagationFlag = true; |
| 102 | + } |
| 103 | + |
| 104 | + /** @deprecated */ |
| 105 | + get cancelBubble() { |
| 106 | + // @ts-ignore - this is a hack to make the URL object work |
| 107 | + return this.stopPropagationFlag; |
| 108 | + } |
| 109 | + |
| 110 | + set cancelBubble(value) { |
| 111 | + // TODO |
| 112 | + // this.stopPropagationFlag = webidl.converters.boolean(value); |
| 113 | + } |
| 114 | + |
| 115 | + stopImmediatePropagation() { |
| 116 | + // @ts-ignore - this is a hack to make the URL object work |
| 117 | + |
| 118 | + this.stopPropagationFlag = true; |
| 119 | + // @ts-ignore - this is a hack to make the URL object work |
| 120 | + this.stopImmediatePropagationFlag = true; |
| 121 | + } |
| 122 | + |
| 123 | + get bubbles() { |
| 124 | + // @ts-ignore - this is a hack to make the URL object work |
| 125 | + return this.attributes.bubbles; |
| 126 | + } |
| 127 | + |
| 128 | + get cancelable() { |
| 129 | + // @ts-ignore - this is a hack to make the URL object work |
| 130 | + return this.attributes.cancelable; |
| 131 | + } |
| 132 | + |
| 133 | + get returnValue() { |
| 134 | + // @ts-ignore - this is a hack to make the URL object work |
| 135 | + return !this.canceledFlag; |
| 136 | + } |
| 137 | + |
| 138 | + set returnValue(value) { |
| 139 | + // if (!webidl.converters.boolean(value)) { |
| 140 | + // @ts-ignore - this is a hack to make the URL object work |
| 141 | + this.canceledFlag = true; |
| 142 | + // } |
| 143 | + } |
| 144 | + |
| 145 | + preventDefault() { |
| 146 | + // if (this.attributes.cancelable && !this.inPassiveListener) { |
| 147 | + // @ts-ignore - this is a hack to make the URL object work |
| 148 | + this.canceledFlag = true; |
| 149 | + // } |
| 150 | + } |
| 151 | + |
| 152 | + get defaultPrevented() { |
| 153 | + // @ts-ignore - this is a hack to make the URL object work |
| 154 | + return this.canceledFlag; |
| 155 | + } |
| 156 | + |
| 157 | + get composed() { |
| 158 | + // @ts-ignore - this is a hack to make the URL object work |
| 159 | + return this.attributes.composed; |
| 160 | + } |
| 161 | + |
| 162 | + get initialized() { |
| 163 | + return true; |
| 164 | + } |
| 165 | + |
| 166 | + get timeStamp() { |
| 167 | + // @ts-ignore - this is a hack to make the URL object work |
| 168 | + return this.attributes.timeStamp; |
| 169 | + } |
| 170 | +} |
0 commit comments