From d0cf318477e148883b88a10dc30686f04a224df3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caridy=20Pati=C3=B1o?= Date: Tue, 31 Jul 2018 20:04:50 -0400 Subject: [PATCH] fix(engine): never access props from proxies (#546) * fix(engine): never access props from proxies * fix(engine): never access props from proxies * fix(engine): never access props from proxies --- .../lwc-engine/src/faux-shadow/shadow-root.ts | 26 +++---------------- .../lwc-engine/src/faux-shadow/traverse.ts | 4 --- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/packages/lwc-engine/src/faux-shadow/shadow-root.ts b/packages/lwc-engine/src/faux-shadow/shadow-root.ts index 303449c4e6..d0a5311237 100644 --- a/packages/lwc-engine/src/faux-shadow/shadow-root.ts +++ b/packages/lwc-engine/src/faux-shadow/shadow-root.ts @@ -1,11 +1,11 @@ import assert from "../shared/assert"; -import { isNull, create, assign, isUndefined, toString, getOwnPropertyDescriptor, ArrayReduce, } from "../shared/language"; +import { create, assign, isUndefined, getOwnPropertyDescriptor, ArrayReduce } from "../shared/language"; import { addShadowRootEventListener, removeShadowRootEventListener } from "./events"; -import { shadowRootQuerySelector, shadowRootQuerySelectorAll, shadowRootChildNodes, getPatchedCustomElement, isNodeOwnedBy } from "./traverse"; +import { shadowRootQuerySelector, shadowRootQuerySelectorAll, shadowRootChildNodes, isNodeOwnedBy } from "./traverse"; import { getInternalField, setInternalField, createFieldName } from "../shared/fields"; import { getInnerHTML } from "../3rdparty/polymer/inner-html"; import { getTextContent } from "../3rdparty/polymer/text-content"; -import { compareDocumentPosition, DOCUMENT_POSITION_CONTAINED_BY, getNodeKey } from "./node"; +import { compareDocumentPosition, DOCUMENT_POSITION_CONTAINED_BY } from "./node"; // it is ok to import from the polyfill since they always go hand-to-hand anyways. import { ElementPrototypeAriaPropertyNames } from "../polyfills/aria-properties/polyfill"; import { unwrap } from "./traverse-membrane"; @@ -155,16 +155,6 @@ const ArtificialShadowRootDescriptors: PropertyDescriptorMap = { querySelector: { value(this: ShadowRoot, selector: string): Element | null { const node = shadowRootQuerySelector(this, selector); - if (process.env.NODE_ENV !== 'production') { - const host = getHost(this); - const isRoot = isUndefined(getNodeKey(host)); - if (isNull(node) && !isRoot) { - // note: we don't show errors for root elements since their light dom is always empty in fallback mode - if (getPatchedCustomElement(host).querySelector(selector)) { - assert.logWarning(`this.template.querySelector() can only return elements from the template declaration of ${toString(host)}. It seems that you are looking for elements that were passed via slots, in which case you should use this.querySelector() instead.`); - } - } - } return node as Element; }, enumerable: true, @@ -173,16 +163,6 @@ const ArtificialShadowRootDescriptors: PropertyDescriptorMap = { querySelectorAll: { value(this: ShadowRoot, selector: string): Element[] { const nodeList = shadowRootQuerySelectorAll(this, selector); - if (process.env.NODE_ENV !== 'production') { - const host = getHost(this); - const isRoot = isUndefined(getNodeKey(host)); - if (nodeList.length === 0 && !isRoot) { - // note: we don't show errors for root elements since their light dom is always empty in fallback mode - if (getPatchedCustomElement(host).querySelector(selector)) { - assert.logWarning(`this.template.querySelectorAll() can only return elements from template declaration of ${toString(host)}. It seems that you are looking for elements that were passed via slots, in which case you should use this.querySelectorAll() instead.`); - } - } - } return nodeList; }, enumerable: true, diff --git a/packages/lwc-engine/src/faux-shadow/traverse.ts b/packages/lwc-engine/src/faux-shadow/traverse.ts index 7b263fce69..d74284351d 100644 --- a/packages/lwc-engine/src/faux-shadow/traverse.ts +++ b/packages/lwc-engine/src/faux-shadow/traverse.ts @@ -33,10 +33,6 @@ import { getTextContent } from "../3rdparty/polymer/text-content"; import { getInnerHTML } from "../3rdparty/polymer/inner-html"; import { getHost, getShadowRoot } from "./shadow-root"; -export function getPatchedCustomElement(element: HTMLElement): HTMLElement { - return traverseMembraneWrap(element); -} - const iFrameContentWindowGetter: (this: HTMLIFrameElement) => Window = getOwnPropertyDescriptor(HTMLIFrameElement.prototype, 'contentWindow')!.get!; function getNodeOwner(node: Node): HTMLElement | null {