-
Notifications
You must be signed in to change notification settings - Fork 394
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
feat(engine-server): initial directory structure with tests #1922
Conversation
fa330d1
to
295b458
Compare
@@ -91,31 +91,31 @@ function getNodeRestrictionsDescriptors( | |||
return { | |||
appendChild: generateDataDescriptor({ | |||
value(this: Node, aChild: Node) { | |||
if (this instanceof Element && isFalse(options.isPortal)) { |
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.
@caridy do you recall why the Element
check was needed here? It was introduced with the lwc:dom="manual"
directive: bd64274#diff-8d59e8cac3f4cb87581a75c21f6d97e7R41-R44. We also don't have any specific test coverage for this either.
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.
Could be due to this:
The restrictions routine getNodeRestrictionsDescriptors
is meant to be invoked for any Node but the portal restrictions are only meant for Elements.
Currently this method is invoked for the host, shadowRoot and all elements. Host and shadowRoot do not need these restrictions.
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 don't remember exactly why, but @ravijayaramappa 's assumptions sound about right. The shadowRoot/fragments are the problem here. We can chat about it.
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.
Good point @ravijayaramappa. I created another PR to work around this issue without relying on instanceof
: #1934
|
||
// This is a temporary workaround to get the @lwc/engine-server to evaluate in node without having | ||
// to inject at runtime. | ||
export const documentObject: Document = typeof document !== 'undefined' ? document : ({} as any); |
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 needs to be fixed at some point for the @lwc/engine-server
to handle AOM and global HTML attributes.
@@ -175,12 +175,6 @@ function BaseLightningElementConstructor(this: LightningElement): LightningEleme | |||
if (isNull(vmBeingConstructed)) { | |||
throw new ReferenceError('Illegal constructor'); | |||
} | |||
if (process.env.NODE_ENV !== 'production') { |
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 check is not needed after the spring cleaning.
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.
PM, can you please elaborate how elm
is guaranteed to be an HTMLElement instance?
It wasn't clear from https://github.com/salesforce/lwc/pull/1893/files how it is guaranteed.
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.
There is no guaranty at the type level. We have struggled since the beginning of the SSR work to find the right balance with typings. We can't check in the engine if a given element is an instance of a give DOM constructor since it couple the engine with the DOM. I am open to any idea on how to work around this.
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 guess we could inject a validation function via the renderer or a similar mechanism?
@@ -243,12 +243,6 @@ export function createVM<HostNode, HostElement>( | |||
renderer: Renderer; | |||
} | |||
): VM { | |||
if (process.env.NODE_ENV !== 'production') { | |||
assert.invariant( | |||
elm instanceof HTMLElement, |
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 wonder why we had this assert?!
looking at the spring20 branch, the type is the same for elm
, so i would assume ts will catch these cases.
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.
Good question, I don't know either.
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.
Verified that this code path is only ever hit internally so we should be able to remove it.
* SPDX-License-Identifier: MIT | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT | ||
*/ | ||
const VOID_ELEMENT_NAMES = new Set([ |
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.
why is this list different than the one used in the html parser ?
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.
Good point, I will extract this to the @lwc/shared
.
@@ -254,7 +254,7 @@ export function getComponentInternalDef(Ctor: unknown, name?: string): Component | |||
|
|||
// Only set prototype for public methods and properties | |||
// No DOM Patching occurs here | |||
export function setElementProto(elm: Element, def: ComponentDef) { |
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.
Any reason to use a generic here? It is not being referenced anywhere.
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.
The HostElement
generic is needed to remove the Element
type of the elm
argument.
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.
That's a good point @ravijayaramappa. I don't think we need the generic here since it is not used in the function or in the retuned type.
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.
Ah, I see what you meant!
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.
LGTM, there are some questions/nit pointed out on the review.
"types/" | ||
], | ||
"devDependencies": { | ||
"@lwc/engine-core": "1.7.1", |
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.
should this be 1.7.2?
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.
Updated to 1.7.2 after rebasing
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.
lgtm
9977cca
to
3591f5f
Compare
Details
Does this PR introduce breaking changes?
No, it does not introduce breaking changes.
The PR fulfills these requirements:
GUS work item