Skip to content

Commit

Permalink
fix(engine): never use a dot notation of patched objects (#410)
Browse files Browse the repository at this point in the history
* Fixes illegal invocations
  • Loading branch information
caridy authored Jun 13, 2018
1 parent 369e073 commit 2c6b1f4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/lwc-engine/src/framework/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ const eventShadowDescriptors: PropertyDescriptorMap = {
return currentTarget;
}
return patchShadowDomTraversalMethods(currentTarget);
}
},
enumerable: true,
configurable: true,
},
target: {
get(this: Event): HTMLElement {
Expand Down Expand Up @@ -148,6 +150,7 @@ const eventShadowDescriptors: PropertyDescriptorMap = {
}
return patchShadowDomTraversalMethods(closestTarget);
},
enumerable: true,
configurable: true,
},
};
Expand Down Expand Up @@ -182,7 +185,7 @@ function getWrappedRootListener(vm: VM, listener: EventListener): WrappedListene
// it is coming from an slotted element
isChildNode(getRootNode.call(target, event), currentTarget as Node) ||
// it is not composed and its is coming from from shadow
(composed === false && getRootNode.call(event.target) === currentTarget)) {
(composed === false && getRootNode.call(target) === currentTarget)) {
patchShadowDomEvent(vm, event);
invokeEventListener(vm, EventListenerContext.ROOT_LISTENER, listener, undefined, event);
}
Expand Down Expand Up @@ -318,7 +321,8 @@ function detachDOMListener(vm: VM, type: string, wrappedListener: WrappedListene

const NON_COMPOSED = { composed: false };
export function isValidEventForCustomElement(event: Event): boolean {
const { target, currentTarget } = event;
const target = eventTargetGetter.call(event);
const currentTarget = eventCurrentTargetGetter.call(event);
const { composed } = event as any;
return (
// it is composed, and we should always get it, or
Expand Down

0 comments on commit 2c6b1f4

Please sign in to comment.