Skip to content

Commit

Permalink
fix(engine): closes #515 by removing lazy init (#517)
Browse files Browse the repository at this point in the history
  • Loading branch information
caridy authored and ekashida committed Aug 17, 2018
1 parent ce9308b commit 38fe207
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 60 deletions.
6 changes: 3 additions & 3 deletions packages/lwc-engine/src/faux-shadow/__tests__/slot.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { LightningElement, getHostShadowRoot } from "../../framework/html-element";
import { createElement } from "../../framework/upgrade";
import { compileTemplate } from 'test-utils';
import { LightningElement, getHostShadowRoot } from "../../framework/html-element";

interface LightningSlotElement extends HTMLSlotElement {
assignedElements(options?: object): Element[];
}

describe.skip('slotchange event', () => {
describe('declarative binding', () {
describe('declarative binding', () => {
// Initialized before each test
let element;

Expand Down Expand Up @@ -39,7 +39,7 @@ describe.skip('slotchange event', () => {
});
});

describe('programmatic binding', () {
describe('programmatic binding', () => {
// Initialized before each test
let element;

Expand Down
107 changes: 50 additions & 57 deletions packages/lwc-engine/src/framework/def.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,6 @@ function isElementComponent(Ctor: any, protoSet?: any[]): boolean {
}

function createComponentDef(Ctor: ComponentConstructor): ComponentDef {
if (globalInitialization) {
// Note: this routine is just to solve the circular dependencies mess introduced by rollup.
globalInitialization();
}
if (process.env.NODE_ENV !== 'production') {
assert.isTrue(isElementComponent(Ctor), `${Ctor} is not a valid component, or does not extends LightningElement from "lwc". You probably forgot to add the extend clause on the class declaration.`);

Expand Down Expand Up @@ -401,58 +397,55 @@ const globalElmDescriptors: PropertyDescriptorMap = create(null, {
[PatchedFlag]: {}
});

let globalInitialization: any = () => {
// Note: this routine is just to solve the circular dependencies mess introduced by rollup.
forEach.call(ElementPrototypeAriaPropertyNames, (propName: string) => {
// Note: intentionally using our in-house getPropertyDescriptor instead of getOwnPropertyDescriptor here because
// in IE11, some properties are on Element.prototype instead of HTMLElement, just to be sure.
const descriptor = getPropertyDescriptor(HTMLElement.prototype, propName);
if (!isUndefined(descriptor)) {
const attrName = getAttrNameFromPropName(propName);
HTML_PROPS[propName] = {
config: 3,
type: 'any',
attr: attrName,
};
const globalElmDescriptor = globalElmDescriptors[propName] = {
get: createGetter(propName),
set: createSetter(propName),
enumerable: true,
configurable: true,
};
defineProperty(globalElmProto, propName, globalElmDescriptor);
GLOBAL_PROPS_DESCRIPTORS[propName] = descriptor;
}
});
forEach.call(defaultDefHTMLPropertyNames, (propName) => {
// Note: intentionally using our in-house getPropertyDescriptor instead of getOwnPropertyDescriptor here because
// in IE11, id property is on Element.prototype instead of HTMLElement, and we suspect that more will fall into
// this category, so, better to be sure.
const descriptor = getPropertyDescriptor(HTMLElement.prototype, propName);
if (!isUndefined(descriptor)) {
const attrName = getAttrNameFromPropName(propName);
HTML_PROPS[propName] = {
config: 3,
type: 'any',
attr: attrName,
};
const globalElmDescriptor = globalElmDescriptors[propName] = {
get: createGetter(propName),
set: createSetter(propName),
enumerable: true,
configurable: true,
};
defineProperty(globalElmProto, propName, globalElmDescriptor);
GLOBAL_PROPS_DESCRIPTORS[propName] = descriptor;
}
});
defineProperties(BaseElement.prototype, createBaseElementStandardPropertyDescriptors(GLOBAL_PROPS_DESCRIPTORS));

if (process.env.NODE_ENV !== 'production') {
patchLightningElementPrototypeWithRestrictions(BaseElement.prototype);
forEach.call(ElementPrototypeAriaPropertyNames, (propName: string) => {
// Note: intentionally using our in-house getPropertyDescriptor instead of getOwnPropertyDescriptor here because
// in IE11, some properties are on Element.prototype instead of HTMLElement, just to be sure.
const descriptor = getPropertyDescriptor(HTMLElement.prototype, propName);
if (!isUndefined(descriptor)) {
const attrName = getAttrNameFromPropName(propName);
HTML_PROPS[propName] = {
config: 3,
type: 'any',
attr: attrName,
};
const globalElmDescriptor = globalElmDescriptors[propName] = {
get: createGetter(propName),
set: createSetter(propName),
enumerable: true,
configurable: true,
};
defineProperty(globalElmProto, propName, globalElmDescriptor);
GLOBAL_PROPS_DESCRIPTORS[propName] = descriptor;
}
});
forEach.call(defaultDefHTMLPropertyNames, (propName) => {
// Note: intentionally using our in-house getPropertyDescriptor instead of getOwnPropertyDescriptor here because
// in IE11, id property is on Element.prototype instead of HTMLElement, and we suspect that more will fall into
// this category, so, better to be sure.
const descriptor = getPropertyDescriptor(HTMLElement.prototype, propName);
if (!isUndefined(descriptor)) {
const attrName = getAttrNameFromPropName(propName);
HTML_PROPS[propName] = {
config: 3,
type: 'any',
attr: attrName,
};
const globalElmDescriptor = globalElmDescriptors[propName] = {
get: createGetter(propName),
set: createSetter(propName),
enumerable: true,
configurable: true,
};
defineProperty(globalElmProto, propName, globalElmDescriptor);
GLOBAL_PROPS_DESCRIPTORS[propName] = descriptor;
}
});

defineProperties(BaseElement.prototype, createBaseElementStandardPropertyDescriptors(GLOBAL_PROPS_DESCRIPTORS));

if (process.env.NODE_ENV !== 'production') {
patchLightningElementPrototypeWithRestrictions(BaseElement.prototype);
}

freeze(BaseElement);
seal(BaseElement.prototype);
globalInitialization = void(0);
};
freeze(BaseElement);
seal(BaseElement.prototype);

0 comments on commit 38fe207

Please sign in to comment.