-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Framework: Replace element-closest with registered vendor script #9750
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
Conversation
|
I wonder if we should just do it for |
|
@youknowriad Yes, I wasn't too sure how we might want to accomplish the "load always" behavior for Maybe a topic for tomorrow's chat? 🙂 |
|
Put another way, ECMAScript and WHATWG/W3 are separate standards, though often used interchangeably as we use modern features and for polyfilling. Should we or shouldn't we abandon attempts to keep them distinct? |
|
|
Is this true? Could you name some such features? Genuinely curious because I'd commented as such that my assumption is that it's only for ECMAScript: |
|
Oh I see now from their ( https://github.com/zloirock/core-js#features Then it becomes a question of: Are we aligned to |
4c6fe51 to
f6916bd
Compare
|
Rebased to account for the now-merged #9794, which simplifies the implementation here a fair bit. I also discovered that newer versions of JSDOM include support for In updating our pinned version, however, I fought with the license checker flagging |
f6916bd to
52cff5f
Compare
|
cc @pento re: changes to |
|
What a can of worms. Updating See: jestjs/jest#6766 |
|
Licenses are the worst. I mean, I get why they don't put an identifier in the I like the |
|
|
||
| // Check if the license we've detected is telling us to look in the license file, instead. | ||
| if ( licenseType && licenseFiles.find( ( licenseFile ) => licenseType.indexOf( licenseFile ) >= 0 ) ) { | ||
| licenseType = undefined; |
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.
What if the license property is pointing a file describing a truly incompatible license? Wouldn't this wrongly allow the license to be considered valid? I expect this to be even more common for non-standard licenses.
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.
Oh! I missed the code immediately following this, where we try to infer the license type from the presence of a 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.
🙂
Newer version is SemVer-compatible with jest-environment-jsdom and includes support for Element#closest out of the box. jsdom/jsdom#1555 Required to ignore license validation for abab because while it is a compatible license (BSD 3-clause), the package's `license` field is malformed for parse. https://github.com/jsdom/abab/blob/4327de3aae348710094d9f3c1f0c1477d9feb865/package.json#L26 https://github.com/jsdom/abab/blob/master/LICENSE.md
Avoids issues with localStorage in JSDOM 11.12 Can be removed when running Jest 23.5.0 or newer See: jestjs/jest#6766 See: jestjs/jest#6792
Also, check if the license defined in package.json is telling us to look in the license file, instead.
65bf762 to
437b39b
Compare
|
Rebased to resolve conflicts. At this point just need a 👍 |
brandonpayton
left a comment
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 tested this in IE11, and everything appears to work as expected. I also checked this in Chrome and observed that the native version of HTMLElement.prototype.closest was intact.
👍 LGTM
| let licenseType = typeof license === 'object' ? license.type : license; | ||
|
|
||
| // Check if the license we've detected is telling us to look in the license file, instead. | ||
| if ( licenseType && licenseFiles.find( ( licenseFile ) => licenseType.indexOf( licenseFile ) >= 0 ) ) { |
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: This is a good place to use String#includes which reads a bit better than an index comparison.
mcsf
left a comment
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 change. :)
Closes #7159
This pull request seeks to eliminate
element-closestdependency and imports from individual packages, instead replacing with a standard polyfill approach via server-side script enqueue.Potential future improvements include:
wp_add_inline_scriptper dependent)Testing instructions:
Verify there are no regressions in
Element#closestbehaviors, notably in IE11 where it is not supported by default. For example, verify that inserting a quote block and ArrowDown'ing through its citation and into the addition of a default block (verifies usage ofElement#closestin WritingFlow's use ofisInSameBlock).