Skip to content

Commit

Permalink
fix: disable shadow and membrane in prod (#372)
Browse files Browse the repository at this point in the history
## Details
Fixing shadowDOM implementation for selenium
  • Loading branch information
diervo authored Jun 3, 2018
1 parent ff89fb7 commit 41149c2
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Component } from "../../component";
describe('root', () => {
describe('integration', () => {

it('should support this.template.host', () => {
it.skip('should support this.template.host', () => {
class MyComponent extends Element {}
const elm = createElement('x-foo', { is: MyComponent });
const vm = elm[ViewModelReflection] as VM;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ describe('#parentNode and #parentElement', () => {
document.body.appendChild(elm);
return Promise.resolve().then(() => {
const root = elm.shadowRoot;
expect(root.querySelector('div').parentNode).toBe(root);
expect(root.querySelector('div').parentElement).toBe(root);
});
});

Expand Down
12 changes: 2 additions & 10 deletions packages/lwc-engine/src/framework/dom/shadow-root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,8 @@ const ArtificialShadowRootPrototype = create({}, ArtificialShadowRootDescriptors
let DevModeBlackListDescriptorMap: PropertyDescriptorMap;

if (process.env.NODE_ENV !== 'production') {
DevModeBlackListDescriptorMap = {
// TODO: do we really want this to return the component?
// It seems that we can remove this entirely to disable the access to the host from within.
host: {
get(this: ShadowRoot) {
const vm = getShadowRootVM(this);
return vm.component;
},
}
};
DevModeBlackListDescriptorMap = {};

const BlackListedShadowRootMethods = {
appendChild: 0,
cloneNode: 0,
Expand Down
9 changes: 5 additions & 4 deletions packages/lwc-engine/src/framework/dom/traverse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@ const shadowDescriptors: PropertyDescriptorMap = {
value: lightDomQuerySelectorAll,
configurable: true,
},
parentNode: {
get: parentNodeDescriptorValue,
configurable: true,
},
// TODO: @dval removes as a temporal fix for selenium internals
// parentNode: {
// get: parentNodeDescriptorValue,
// configurable: true,
// },
parentElement: {
get: parentElementDescriptorValue,
configurable: true,
Expand Down
12 changes: 5 additions & 7 deletions packages/lwc-engine/src/framework/html-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ function ElementShadowRootGetter(this: HTMLElement): ShadowRoot | null {
}

const fallbackDescriptors = {
shadowRoot: {
get: ElementShadowRootGetter,
configurable: true,
enumerable: true,
},
querySelector: {
value: lightDomQuerySelector,
configurable: true,
Expand Down Expand Up @@ -146,13 +151,6 @@ function LWCElement(this: Component) {
defineProperties(elm, def.descriptors);
if (isTrue(fallback)) {
defineProperties(elm, fallbackDescriptors);
if (process.env.NODE_ENV !== 'production') {
defineProperty(elm, 'shadowRoot', {
get: ElementShadowRootGetter,
configurable: true,
enumerable: true,
});
}
}
}

Expand Down

0 comments on commit 41149c2

Please sign in to comment.