MCPcopy
hub / github.com/htmlhint/HTMLHint / fire

Method fire

src/core/htmlparser.ts:244–274  ·  view source on GitHub ↗
(type: string, data?: Partial<Block>)

Source from the content-addressed store, hash-verified

242 }
243
244 public fire(type: string, data?: Partial<Block>): void {
245 if (data === undefined) {
246 data = {}
247 }
248 data.type = type
249
250 let listeners: Listener[] = []
251 const listenersType = this._listeners[type]
252 const listenersAll = this._listeners['all']
253
254 if (listenersType !== undefined) {
255 listeners = listeners.concat(listenersType)
256 }
257 if (listenersAll !== undefined) {
258 listeners = listeners.concat(listenersAll)
259 }
260
261 const lastEvent = this.lastEvent
262 if (lastEvent !== null) {
263 delete lastEvent['lastEvent']
264 data.lastEvent = lastEvent
265 }
266
267 this.lastEvent = data
268
269 for (let i = 0, l = listeners.length; i < l; i++) {
270 // TODO: we may improve where data is actually a Block or a Partial<Block>
271 // @ts-expect-error
272 listeners[i].call(this, data)
273 }
274 }
275
276 public removeListener(type: string, listener: Listener): void {
277 const listenersType: Listener[] | undefined = this._listeners[type]

Callers 2

parseMethod · 0.95
saveBlockMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected