Problem/Motivation
As mentioned in the parent issue #3238306: [META] Where possible, refactor existing jQuery uses to vanillaJS to reduce jQuery footprint, we are working towards reducing our jQuery footprint. One of the ways to accomplish this is to reduce the number of jQuery features used in Drupal core. We have added eslint rules that identify specific features and fail tests when those features are in use.
There are (or will be) individual issues for each jQuery-use eslint rule. This one is specific to jquery/no-is, which targets the jQuery is function.
Steps to reproduce
Proposed resolution
Remaining tasks
- In
core/.eslintrc.jquery.jsonChange"jquery/no-is": 0,to"jquery/no-is": 2,to enable eslint checks for uses of jQuerycss(). With this change, you'll be able to see uses of the undesirable jQuery feature by runningyarn lint:core-js-passingfrom thecoredirectory - Add the following lines to
core/scripts/dev/commit-code-check.shso the DrupalCI testing script can catch this jQuery usage on all files, not just those which have changed
# @todo Remove the next chunk of lines before committing. This script only lints # JavaScript files that have changed, so we add this to check all files for # jQuery-specific lint errors. cd "$TOP_LEVEL/core" node ./node_modules/eslint/bin/eslint.js --quiet --config=.eslintrc.passing.json . CORRECTJQS=$? if [ "$CORRECTJQS" -ne "0" ]; then # No need to write any output the node command will do this for us. printf "${red}FAILURE ${reset}: unsupported jQuery usage. See errors above." STATUS=1 FINAL_STATUS=1 fi cd $TOP_LEVEL # @todo end lines to removeAdd the block about 10 lines before the end of the file, just before
if [[ "$FINAL_STATUS" == "1" ]] && [[ "$DRUPALCI" == "1" ]]; then, then remove it once all the jQuery uses have been refactored. - If it's determined to be feasible, refactor those uses of jQuery
is()to use Vanilla (native) JavaScript instead.
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #26 | interdiff-3238849-22-26.txt | 3.03 KB | mstrelan |
| #26 | 3238849-26.patch | 28.96 KB | mstrelan |
Issue fork drupal-3238849
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
hooroomooComment #3
hooroomooComment #4
hooroomooComment #10
mstrelan commentedTried to rebase on to 9.4.x but failed miserably. Patch attached instead.
Comment #11
mstrelan commentedComment #12
mstrelan commentedComment #14
mstrelan commentedComment #15
mstrelan commentedComment #16
mstrelan commentedComment #18
mstrelan commentedComment #20
mstrelan commentedPatch for 11.x since gitlab won't let me create a new branch.
Comment #21
smustgrave commentedIf the CC could be updated.
Comment #22
mstrelan commentedComment #23
smustgrave commentedWasn't sure how to test.
So I applied locally on 11.x and haven't encountered any issues with the change applied all day.
Let me know if there's a better way. Going to mark for now.
Comment #24
larowlanJust a couple of questions about where we might need to add a length check of optional chaining
Do we need a length check here?
do we need a length check here too? or ?.checked
here too
Comment #25
smustgrave commentedFor #24
Comment #26
mstrelan commented#24.1 it's already inside a length check:
#24.2 and #24.3 how about we use the
:checkedselector and check the length?Comment #27
smustgrave commentedChange didn't seem to break anything!
Comment #29
larowlanCommitted cd9fed8 and pushed to 11.x. Thanks!
Comment #31
joseph.olstad***EDIT***
no comment for now
***EDIT***
Comment #32
berdirI'm getting JS errors in multiple Paragraph Browser tests on line 62 around the checkbox stuff that was discussed above. Created #3393537: Javascript errors in entity-form.js when retranslate checkbox does not exist.
Comment #33
nod_another regression
Comment #34
nod_