-
Notifications
You must be signed in to change notification settings - Fork 402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(engine): closes #515 by removing lazy init #517
Merged
ekashida
merged 1 commit into
master
from
caridy/fix-issue-515-lazy-initialization-locker
Aug 17, 2018
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -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.`); | ||
|
||
|
@@ -401,58 +397,55 @@ const globalElmDescriptors: PropertyDescriptorMap = create(null, { | |
[PatchedFlag]: {} | ||
}); | ||
|
||
let globalInitialization: any = () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removing the method to just run the code directly during evaluation instead of lazily. |
||
// 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); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one still exhibit the circular issue, but changing the order fixes it for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to talk about this. If the import order mater then we still have a circular dependency issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a suggestion: We should use a tool(for example: https://github.com/pahen/madge) to generate a dependency graph of the modules and remove any cyclic dependencies.