-
Notifications
You must be signed in to change notification settings - Fork 403
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): fixes #973 to support cloneNode with ie11 devtool comment #974
Conversation
Benchmark resultsBase commit: lwc-engine-benchmark
|
Benchmark resultsBase commit: lwc-engine-benchmark
|
while (!isNull(ownerNode)) { | ||
if (!isUndefined(ownerNode[OwnerKey])) { | ||
return ownerNode[OwnerKey]; | ||
} else if (!isUndefined(ownerNode[OwnKey])) { |
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 was causing that for accessing stuff off the root element, it has to traverse all the way to the top (document) to find that that it doesn't have an owner.
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.
additionally, for some reason, IE11 was complaining about this being part of the while statement, so moving it into here makes sense.
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.
We are inferring that the node is a host element by checking for a key. Can you make it an util like isHostElement()
so that the intention is clear and the check can be reused.
export function isExternalChildNodeAccessorFlagOn(): boolean { | ||
return !setInternalChildNodeAccessorFlag; | ||
} | ||
export const getInternalChildNodes = (process.env.NODE_ENV !== 'production' && isFalse(hasNativeSymbolsSupport)) ? |
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.
whenever we use childNodes inside farmework code, we need to go thru this method, otherwise we might get the comment for devtool in IE11
} | ||
return childNodes; | ||
} : function getExternalChildNodes(node: Node): NodeListOf<ChildNode> { | ||
return node.childNodes; |
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.
in other modes, non-ie11, no devmode, we do nothing but getting the childNodes off the node.
// At this point, node is a valid node with owner identity, now we need to find the owner node | ||
// search for a custom element with a VM that owns the first element with owner identity attached to it | ||
while (!isNull(node) && (getNodeKey(node) !== ownerKey)) { | ||
node = parentNodeGetter.call(node); | ||
while (!isNull(nodeOwner) && (getNodeKey(nodeOwner) !== ownerKey)) { |
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 fixing types... nothing else.
if (elmOwnerKey === hostKey) { | ||
// we have reached a host's node element, and only if | ||
// that element is an slot, then the node is considered slotted | ||
return isSlotElement(currentElement); | ||
} else if (parent !== host && getNodeNearestOwnerKey(parent) !== elmOwnerKey) { | ||
} else if (!isNull(parent) && parent !== host && getNodeNearestOwnerKey(parent) !== elmOwnerKey) { |
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.
guarding against checking for elements being slotted for manually inserted nodes. this could cause issues, but I don't have a concrete example for a test for this guarding, but the type system was definitely complaining about it.
Benchmark resultsBase commit: lwc-engine-benchmark
|
Benchmark resultsBase commit: lwc-engine-benchmark
|
I see 3 non-related compat test failures, but I don't know if these are flappers or not. |
@@ -276,3 +285,36 @@ export function PatchedNode(node: Node): NodeConstructor { | |||
setPrototypeOf(PatchedNodeClass.prototype, Ctor.prototype); | |||
return (PatchedNodeClass as any) as NodeConstructor; | |||
} | |||
|
|||
let setInternalChildNodeAccessorFlag = false; |
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.
nit pick
setInternalChildNodeAccessorFlag
=> internalChildNodeAccessorFlag
This is the flag itself, so using a verb in its name seems incorrect.
|
||
/** | ||
* These 2 methods are providing a machinery to understand who is accessing the | ||
* .childNode member property of a node. If it is used from inside the synthetic shadow |
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.
typo .childNode member property
=> childNodes member property
} | ||
} | ||
return childNodes; | ||
} : function getExternalChildNodes(node: Node): NodeListOf<ChildNode> { |
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 why this function is not an anonymous function?
Also why not an arrow function?
try { | ||
childNodes = node.childNodes; | ||
} catch (e) { | ||
// childNode accessor should never throw, but just in case! |
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.
childNode accessor
=> childNodes accessor
Benchmark resultsBase commit: lwc-engine-benchmark
|
I still see 2 compat failures... not sure... |
@@ -31,6 +32,8 @@ import { getShadowRoot } from './shadow-root'; | |||
const OwnerKey = '$$OwnerKey$$'; | |||
const OwnKey = '$$OwnKey$$'; | |||
|
|||
export const hasNativeSymbolsSupport = Symbol('x').toString() === 'Symbol(x)'; |
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.
Let's reuse the shared version:
const hasNativeSymbolsSupport = Symbol('x').toString() === 'Symbol(x)'; |
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 one might change in the future once we have the weakmaps, so let's keep them separate. Also we plan to disconnect engine from synthetic.
Benchmark resultsBase commit: lwc-engine-benchmark
|
confirmed that the failures are flapper :( I'm merging this, and we can prepare the patch branch. |
Details
Does this PR introduce a breaking change?