-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: inclusao dos processos de adopted attributeChanged connected di…
…dPaint diconnected e on
- Loading branch information
1 parent
1a4e979
commit edc9e37
Showing
1 changed file
with
28 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,36 @@ | ||
const on = new Proxy( | ||
{}, | ||
{ | ||
get (_, event) { | ||
return (query) => (target, propertyKey) => { | ||
const connectedCallback = target.connectedCallback ?? (() => undefined); | ||
{}, | ||
{ | ||
get(_, event) { | ||
return (query) => (target, propertyKey) => { | ||
const connectedCallback = target.connectedCallback ?? (() => undefined); | ||
|
||
const disconnectedCallback = | ||
target.disconnectedCallback ?? (() => undefined); | ||
const disconnectedCallback = | ||
target.disconnectedCallback ?? (() => undefined); | ||
|
||
function listener(this, event) { | ||
event.target.matches(query) && this[propertyKey](event); | ||
} | ||
function listener(event) { | ||
event.target.matches(query) && this[propertyKey](event); | ||
} | ||
|
||
Reflect.defineProperty(target, "connectedCallback", { | ||
async value() { | ||
listener.bind(this) | ||
await Reflect.apply(connectedCallback, this, arguments); | ||
await this.shadowRoot.addEventListener(event, listener); | ||
}, | ||
writable: true, | ||
}); | ||
Reflect.defineProperty(target, "connectedCallback", { | ||
async value() { | ||
listener.bind(this); | ||
await Reflect.apply(connectedCallback, this, arguments); | ||
await this.shadowRoot.addEventListener(event, listener); | ||
}, | ||
writable: true, | ||
}); | ||
|
||
Reflect.defineProperty(target, "disconnectedCallback", { | ||
async value() { | ||
await Reflect.apply(disconnectedCallback, this, arguments); | ||
await this.shadowRoot.removeEventListener(event, listener); | ||
}, | ||
writable: true, | ||
}); | ||
}; | ||
}, | ||
}, | ||
Reflect.defineProperty(target, "disconnectedCallback", { | ||
async value() { | ||
await Reflect.apply(disconnectedCallback, this, arguments); | ||
await this.shadowRoot.removeEventListener(event, listener); | ||
}, | ||
writable: true, | ||
}); | ||
}; | ||
}, | ||
}, | ||
); | ||
|
||
export default on; |