-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Coreify specific layout.js, CE, and BE functions #34810
Conversation
Hey @jridgewell! These files were changed:
|
return true; | ||
} | ||
return 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.
Nice! More core! I think it would make sense for this whole file to live in src/core/dom/layout
, with the only exception being the applyStaticLayout helpers that have dependencies on the experiment system
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.
Yes! But that requires changing 100s of files import paths and so I'd rather do it separately since my main goal is to unblock #34770
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.
If I understand correctly, this is only used in custom-element. What's the motivation for moving it into core, rather than closer to CE?
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.
Created #34818 to unblock any dependencies on layout
; diff looks like 2ee75c4...cc4d48b excluding the import updates and actual moves
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.
Compiler will need to run it, and we don't want compiler to need an instance of CustomElement
to run.
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.
Maybe just a helper in custom-element.js
then?
if (opt_replacedContent) { | ||
element.classList.add('i-amphtml-replaced-content'); | ||
} | ||
applyFillContent(element, opt_replacedContent); |
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.
Would it make sense for applyFillContent
to be defined locally in this file?
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.
Still relevant, since we don't really want other code using this instead of element.applyFillContent
. Including it in core
kinda implies it's fine, whereas no one will go out of their way to import it from here (except the compiler)
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.
Sure, I'm fine with that
This has been superseded by a few other PRs: #34818, #34858, and #34813 (comment) |
summary
Core-ifies specific functions needed for #34770.
The functions are:
getRealChildNodes
,isInternalOrServiceNode
, andapplyFillContent
Turns out that the typing for the very old function
isInternalOrServiceNode
has been wrong this whole time.I wonder if our new type checking is more strict than it had originally been. Calling
node.tagName
andnode.hasAttribute
is incorrect because aNode
could be a comment node or a text node. I fix that by adding a check for ELEMENT_NODE at the top.