Skip to content

Commit eb1724f

Browse files
dependabot[bot]Daz
authored andcommitted
Bump elliptic from 6.5.7 to 6.6.1 in /examples
Bumps [elliptic](https://github.com/indutny/elliptic) from 6.5.7 to 6.6.1. - [Commits](indutny/elliptic@v6.5.7...v6.6.1) --- updated-dependencies: - dependency-name: elliptic dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Bump ejs from 3.1.7 to 3.1.10 in /examples Bumps [ejs](https://github.com/mde/ejs) from 3.1.7 to 3.1.10. - [Release notes](https://github.com/mde/ejs/releases) - [Commits](mde/ejs@v3.1.7...v3.1.10) --- updated-dependencies: - dependency-name: ejs dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> Bump webpack-dev-middleware from 3.7.3 to 5.3.4 in /examples Bumps [webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware) from 3.7.3 to 5.3.4. - [Release notes](https://github.com/webpack/webpack-dev-middleware/releases) - [Changelog](https://github.com/webpack/webpack-dev-middleware/blob/v5.3.4/CHANGELOG.md) - [Commits](webpack/webpack-dev-middleware@v3.7.3...v5.3.4) --- updated-dependencies: - dependency-name: webpack-dev-middleware dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> Update 02_hello_stimulus.md Update 03_building_something_real.md add emphasis to the outlet naming #669 (comment) this error is so hard to track down that I added some emphasis and hopefully the search engines will point to this. initial try at patching methods typescript fixes added tests updated methods to get classes working adding tests back in and tidying up initial try at patching methods updated methods to get classes working adding tests back in and tidying up
1 parent 8be51e5 commit eb1724f

File tree

8 files changed

+163
-59
lines changed

8 files changed

+163
-59
lines changed

docs/handbook/02_hello_stimulus.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ We'll finish the exercise by changing our action to say hello to whatever name w
133133

134134
In order to do that, first we need a reference to the input element inside our controller. Then we can read the `value` property to get its contents.
135135

136-
Stimulus lets us mark important elements as _targets_ so we can easily reference them in the controller through corresponding properties. Open `public/index.html` and add a `data-hello-target` attribute to the input element:
136+
Stimulus lets us mark important child elements as _targets_ so we can easily reference them in the controller through corresponding properties. Open `public/index.html` and add a `data-hello-target` attribute to the input element:
137137

138138
```html
139139
<div data-controller="hello">

docs/handbook/03_building_something_real.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ Now let's add one more PIN field. This time we'll use a Copy _link_ instead of a
145145
</div>
146146
```
147147

148-
Stimulus lets us use any kind of element we want as long as it has an appropriate `data-action` attribute.
148+
Stimulus lets us use any kind of element we want as long as it has an appropriate `data-action` attribute, and is a child of the controller component.
149149

150150
Note that in this case, clicking the link will also cause the browser to follow the link's `href`. We can cancel this default behavior by calling `event.preventDefault()` in the action:
151151

docs/reference/outlets.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ While a **target** is a specifically marked element **within the scope** of its
3333

3434
## Attributes and Names
3535

36-
The `data-chat-user-status-outlet` attribute is called an _outlet attribute_, and its value is a [CSS selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors) which you can use to refer to other controller elements which should be available as outlets on the _host controller_. The outlet identifier in the host controller must be the same as the target controller's identifier.
36+
The `data-chat-user-status-outlet` attribute is called an _outlet attribute_, and its value is a [CSS selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors) which you can use to refer to other controller elements which should be available as outlets on the _host controller_. The outlet identifier in the host controller **must be the same** as the target controller's identifier. If not, it will throw an error message that outlet does not exist.
3737

3838
```html
3939
data-[identifier]-[outlet]-outlet="[selector]"

examples/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
"@babel/preset-env": "^7.5.5",
1010
"@hotwired/turbo": "^7.2.4",
1111
"babel-loader": "^8.0.6",
12-
"ejs": "^3.1.7",
12+
"ejs": "^3.1.10",
1313
"express": "^4.20.0",
1414
"webpack": "^4.39.1",
15-
"webpack-dev-middleware": "^3.7.0"
15+
"webpack-dev-middleware": "^5.3.4"
1616
},
1717
"scripts": {
1818
"start": "node server.js"

examples/yarn.lock

Lines changed: 87 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,6 +1050,11 @@
10501050
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.8.tgz#edf1bf1dbf4e04413ca8e5b17b3b7d7d54b59818"
10511051
integrity sha512-YSBPTLTVm2e2OoQIDYx8HaeWJ5tTToLH67kXR7zYNGupXMEHa2++G8k+DczX2cFVgalypqtyZIcU19AFcmOpmg==
10521052

1053+
"@types/json-schema@^7.0.9":
1054+
version "7.0.15"
1055+
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841"
1056+
integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==
1057+
10531058
"@webassemblyjs/[email protected]":
10541059
version "1.9.0"
10551060
resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.9.0.tgz#bd850604b4042459a5a41cd7d338cbed695ed964"
@@ -1223,11 +1228,25 @@ ajv-errors@^1.0.0:
12231228
resolved "https://registry.yarnpkg.com/ajv-errors/-/ajv-errors-1.0.1.tgz#f35986aceb91afadec4102fbd85014950cefa64d"
12241229
integrity sha512-DCRfO/4nQ+89p/RK43i8Ezd41EqdGIU4ld7nGF8OQ14oc/we5rEntLCUa7+jrn3nn83BosfwZA0wb4pon2o8iQ==
12251230

1231+
ajv-formats@^2.1.1:
1232+
version "2.1.1"
1233+
resolved "https://registry.yarnpkg.com/ajv-formats/-/ajv-formats-2.1.1.tgz#6e669400659eb74973bbf2e33327180a0996b520"
1234+
integrity sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==
1235+
dependencies:
1236+
ajv "^8.0.0"
1237+
12261238
ajv-keywords@^3.1.0, ajv-keywords@^3.4.1, ajv-keywords@^3.5.2:
12271239
version "3.5.2"
12281240
resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d"
12291241
integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==
12301242

1243+
ajv-keywords@^5.1.0:
1244+
version "5.1.0"
1245+
resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-5.1.0.tgz#69d4d385a4733cdbeab44964a1170a88f87f0e16"
1246+
integrity sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw==
1247+
dependencies:
1248+
fast-deep-equal "^3.1.3"
1249+
12311250
ajv@^6.1.0, ajv@^6.10.2, ajv@^6.12.4:
12321251
version "6.12.6"
12331252
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4"
@@ -1238,10 +1257,15 @@ ajv@^6.1.0, ajv@^6.10.2, ajv@^6.12.4:
12381257
json-schema-traverse "^0.4.1"
12391258
uri-js "^4.2.2"
12401259

1241-
ansi-colors@^3.0.0:
1242-
version "3.2.4"
1243-
resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-3.2.4.tgz#e3a3da4bfbae6c86a9c285625de124a234026fbf"
1244-
integrity sha512-hHUXGagefjN2iRrID63xckIvotOXOojhQKWIPUZ4mNUZ9nLZW+7FMNoE1lOkEhNWYsx/7ysGIuJYCiMAA9FnrA==
1260+
ajv@^8.0.0, ajv@^8.9.0:
1261+
version "8.17.1"
1262+
resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.17.1.tgz#37d9a5c776af6bc92d7f4f9510eba4c0a60d11a6"
1263+
integrity sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==
1264+
dependencies:
1265+
fast-deep-equal "^3.1.3"
1266+
fast-uri "^3.0.1"
1267+
json-schema-traverse "^1.0.0"
1268+
require-from-string "^2.0.2"
12451269

12461270
ansi-styles@^3.2.1:
12471271
version "3.2.1"
@@ -1785,6 +1809,11 @@ colorette@^1.2.2:
17851809
resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.2.2.tgz#cbcc79d5e99caea2dbf10eb3a26fd8b3e6acfa94"
17861810
integrity sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w==
17871811

1812+
colorette@^2.0.10:
1813+
version "2.0.20"
1814+
resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.20.tgz#9eb793e6833067f7235902fcd3b09917a000a95a"
1815+
integrity sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==
1816+
17881817
commander@^2.20.0:
17891818
version "2.20.3"
17901819
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
@@ -2041,10 +2070,10 @@ [email protected]:
20412070
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
20422071
integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=
20432072

2044-
ejs@^3.1.7:
2045-
version "3.1.7"
2046-
resolved "https://registry.yarnpkg.com/ejs/-/ejs-3.1.7.tgz#c544d9c7f715783dd92f0bddcf73a59e6962d006"
2047-
integrity sha512-BIar7R6abbUxDA3bfXrO4DSgwo8I+fB5/1zgujl3HLLjwd6+9iOnrT+t3grn2qbk9vOgBubXOFwX2m9axoFaGw==
2073+
ejs@^3.1.10:
2074+
version "3.1.10"
2075+
resolved "https://registry.yarnpkg.com/ejs/-/ejs-3.1.10.tgz#69ab8358b14e896f80cc39e62087b88500c3ac3b"
2076+
integrity sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==
20482077
dependencies:
20492078
jake "^10.8.5"
20502079

@@ -2054,9 +2083,9 @@ electron-to-chromium@^1.3.723:
20542083
integrity sha512-nreave0y/1Qhmo8XtO6C/LpawNyC6U26+q7d814/e+tIqUK073pM+4xW7WUXyqCRa5K4wdxHmNMBAi8ap9nEew==
20552084

20562085
elliptic@^6.5.3, elliptic@^6.5.4:
2057-
version "6.5.7"
2058-
resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.7.tgz#8ec4da2cb2939926a1b9a73619d768207e647c8b"
2059-
integrity sha512-ESVCtTwiA+XhY3wyh24QqRGBoP3rEdDUl3EDUUo9tft074fi19IrdpH7hLCMMP3CIj7jb3W96rn8lt/BqIlt5Q==
2086+
version "6.6.1"
2087+
resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.6.1.tgz#3b8ffb02670bf69e382c7f65bf524c97c5405c06"
2088+
integrity sha512-RaddvvMatK2LJHqFJ+YA4WysVN5Ita9E35botqIYspQ4TkRAlCicdzKOjlyv/1Za5RyTNn7di//eEV0uTAfe3g==
20602089
dependencies:
20612090
bn.js "^4.11.9"
20622091
brorand "^1.1.0"
@@ -2258,7 +2287,7 @@ extglob@^2.0.4:
22582287
snapdragon "^0.8.1"
22592288
to-regex "^3.0.1"
22602289

2261-
fast-deep-equal@^3.1.1:
2290+
fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
22622291
version "3.1.3"
22632292
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
22642293
integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==
@@ -2268,6 +2297,11 @@ fast-json-stable-stringify@^2.0.0:
22682297
resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633"
22692298
integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==
22702299

2300+
fast-uri@^3.0.1:
2301+
version "3.0.6"
2302+
resolved "https://registry.yarnpkg.com/fast-uri/-/fast-uri-3.0.6.tgz#88f130b77cfaea2378d56bf970dea21257a68748"
2303+
integrity sha512-Atfo14OibSv5wAp4VWNsFYE1AchQRTv9cBGWET4pZWHzYshFSS9NQI6I57rdKn9croWVMbYFbLhJ+yJvmZIIHw==
2304+
22712305
figgy-pudding@^3.5.1:
22722306
version "3.5.2"
22732307
resolved "https://registry.yarnpkg.com/figgy-pudding/-/figgy-pudding-3.5.2.tgz#b4eee8148abb01dcf1d1ac34367d59e12fa61d6e"
@@ -2386,6 +2420,11 @@ from2@^2.1.0:
23862420
inherits "^2.0.1"
23872421
readable-stream "^2.0.0"
23882422

2423+
fs-monkey@^1.0.4:
2424+
version "1.0.6"
2425+
resolved "https://registry.yarnpkg.com/fs-monkey/-/fs-monkey-1.0.6.tgz#8ead082953e88d992cf3ff844faa907b26756da2"
2426+
integrity sha512-b1FMfwetIKymC0eioW7mTywihSQE4oLzQn1dB6rZB5fx/3NpNEdAWeCSMB+60/AeT0TCXsxzAlcYVEFCTAksWg==
2427+
23892428
fs-write-stream-atomic@^1.0.8:
23902429
version "1.0.10"
23912430
resolved "https://registry.yarnpkg.com/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.10.tgz#b47df53493ef911df75731e70a9ded0189db40c9"
@@ -2856,6 +2895,11 @@ json-schema-traverse@^0.4.1:
28562895
resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660"
28572896
integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==
28582897

2898+
json-schema-traverse@^1.0.0:
2899+
version "1.0.0"
2900+
resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz#ae7bcb3656ab77a73ba5c49bf654f38e6b6860e2"
2901+
integrity sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==
2902+
28592903
json5@^1.0.1:
28602904
version "1.0.2"
28612905
resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.2.tgz#63d98d60f21b313b77c4d6da18bfa69d80e1d593"
@@ -2976,6 +3020,13 @@ [email protected]:
29763020
resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748"
29773021
integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=
29783022

3023+
memfs@^3.4.3:
3024+
version "3.6.0"
3025+
resolved "https://registry.yarnpkg.com/memfs/-/memfs-3.6.0.tgz#d7a2110f86f79dd950a8b6df6d57bc984aa185f6"
3026+
integrity sha512-EGowvkkgbMcIChjMTMkESFDbZeSh8xZ7kNSF0hAiAN4Jh6jgHCRS0Ga/+C8y6Au+oqpezRHCfPsmJ2+DwAgiwQ==
3027+
dependencies:
3028+
fs-monkey "^1.0.4"
3029+
29793030
memory-fs@^0.4.1:
29803031
version "0.4.1"
29813032
resolved "https://registry.yarnpkg.com/memory-fs/-/memory-fs-0.4.1.tgz#3a9a20b8462523e447cfbc7e8bb80ed667bfc552"
@@ -3029,24 +3080,12 @@ miller-rabin@^4.0.0:
30293080
bn.js "^4.0.0"
30303081
brorand "^1.0.1"
30313082

3032-
3033-
version "1.48.0"
3034-
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.48.0.tgz#e35b31045dd7eada3aaad537ed88a33afbef2d1d"
3035-
integrity sha512-FM3QwxV+TnZYQ2aRqhlKBMHxk10lTbMt3bBkMAp54ddrNeVSfcQYOOKuGuy3Ddrm38I04If834fOUSq1yzslJQ==
3036-
30373083
30383084
version "1.52.0"
30393085
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70"
30403086
integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==
30413087

3042-
mime-types@~2.1.24:
3043-
version "2.1.31"
3044-
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.31.tgz#a00d76b74317c61f9c2db2218b8e9f8e9c5c9e6b"
3045-
integrity sha512-XGZnNzm3QvgKxa8dpzyhFTHmpP3l5YNusmne07VUOXxou9CqUqYa/HBy124RqtVh/O2pECas/MOcsDgpilPOPg==
3046-
dependencies:
3047-
mime-db "1.48.0"
3048-
3049-
mime-types@~2.1.34:
3088+
mime-types@^2.1.31, mime-types@~2.1.24, mime-types@~2.1.34:
30503089
version "2.1.35"
30513090
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a"
30523091
integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==
@@ -3058,11 +3097,6 @@ [email protected]:
30583097
resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1"
30593098
integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==
30603099

3061-
mime@^2.4.4:
3062-
version "2.5.2"
3063-
resolved "https://registry.yarnpkg.com/mime/-/mime-2.5.2.tgz#6e3dc6cc2b9510643830e5f19d5cb753da5eeabe"
3064-
integrity sha512-tqkh47FzKeCPD2PUiPB6pkbMzsCasjxAfC62/Wap5qrUWcb+sFasXUC5I3gYM5iBM8v/Qpn4UK0x+j0iHyFPDg==
3065-
30663100
minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1:
30673101
version "1.0.1"
30683102
resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7"
@@ -3683,6 +3717,11 @@ repeat-string@^1.6.1:
36833717
resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637"
36843718
integrity sha1-jcrkcOHIirwtYA//Sndihtp15jc=
36853719

3720+
require-from-string@^2.0.2:
3721+
version "2.0.2"
3722+
resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.2.tgz#89a7fdd938261267318eafe14f9c32e598c36909"
3723+
integrity sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==
3724+
36863725
resolve-url@^0.2.1:
36873726
version "0.2.1"
36883727
resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a"
@@ -3763,6 +3802,16 @@ schema-utils@^2.6.5:
37633802
ajv "^6.12.4"
37643803
ajv-keywords "^3.5.2"
37653804

3805+
schema-utils@^4.0.0:
3806+
version "4.3.2"
3807+
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-4.3.2.tgz#0c10878bf4a73fd2b1dfd14b9462b26788c806ae"
3808+
integrity sha512-Gn/JaSk/Mt9gYubxTtSn/QCV4em9mpAPiR1rqy/Ocu19u/G9J5WWdNoUT4SiV6mFC3y6cxyFcFwdzPM3FgxGAQ==
3809+
dependencies:
3810+
"@types/json-schema" "^7.0.9"
3811+
ajv "^8.9.0"
3812+
ajv-formats "^2.1.1"
3813+
ajv-keywords "^5.1.0"
3814+
37663815
37673816
version "7.0.0"
37683817
resolved "https://registry.yarnpkg.com/semver/-/semver-7.0.0.tgz#5f3ca35761e47e05b206c6daff2cf814f0316b8e"
@@ -4262,11 +4311,6 @@ [email protected]:
42624311
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"
42634312
integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=
42644313

4265-
uuid@^3.3.2:
4266-
version "3.4.0"
4267-
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
4268-
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==
4269-
42704314
vary@~1.1.2:
42714315
version "1.1.2"
42724316
resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"
@@ -4295,24 +4339,16 @@ watchpack@^1.7.4:
42954339
chokidar "^3.4.1"
42964340
watchpack-chokidar2 "^2.0.1"
42974341

4298-
webpack-dev-middleware@^3.7.0:
4299-
version "3.7.3"
4300-
resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-3.7.3.tgz#0639372b143262e2b84ab95d3b91a7597061c2c5"
4301-
integrity sha512-djelc/zGiz9nZj/U7PTBi2ViorGJXEWo/3ltkPbDyxCXhhEXkW0ce99falaok4TPj+AsxLiXJR0EBOb0zh9fKQ==
4342+
webpack-dev-middleware@^5.3.4:
4343+
version "5.3.4"
4344+
resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-5.3.4.tgz#eb7b39281cbce10e104eb2b8bf2b63fce49a3517"
4345+
integrity sha512-BVdTqhhs+0IfoeAf7EoH5WE+exCmqGerHfDM0IL096Px60Tq2Mn9MAbnaGUe6HiMa41KMCYF19gyzZmBcq/o4Q==
43024346
dependencies:
4303-
memory-fs "^0.4.1"
4304-
mime "^2.4.4"
4305-
mkdirp "^0.5.1"
4347+
colorette "^2.0.10"
4348+
memfs "^3.4.3"
4349+
mime-types "^2.1.31"
43064350
range-parser "^1.2.1"
4307-
webpack-log "^2.0.0"
4308-
4309-
webpack-log@^2.0.0:
4310-
version "2.0.0"
4311-
resolved "https://registry.yarnpkg.com/webpack-log/-/webpack-log-2.0.0.tgz#5b7928e0637593f119d32f6227c1e0ac31e1b47f"
4312-
integrity sha512-cX8G2vR/85UYG59FgkoMamwHUIkSSlV3bBMRsbxVXVUk2j6NleCKjQ/WE9eYg9WY4w25O9w8wKP4rzNZFmUcUg==
4313-
dependencies:
4314-
ansi-colors "^3.0.0"
4315-
uuid "^3.3.2"
4351+
schema-utils "^4.0.0"
43164352

43174353
webpack-sources@^1.4.0, webpack-sources@^1.4.1:
43184354
version "1.4.3"

src/core/controller.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ export class Controller<ElementType extends Element = Element> {
7373
return this.scope.data
7474
}
7575

76+
findElement(selector: string) {
77+
return this.scope.findElement(selector)
78+
}
79+
80+
findAllElements(selector: string) {
81+
return this.scope.findAllElements(selector)
82+
}
83+
7684
initialize() {
7785
// Override in your subclass to set up initial controller state
7886
}

src/core/scope.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,38 @@ export class Scope {
2626
}
2727

2828
findElement(selector: string): Element | undefined {
29-
return this.element.matches(selector) ? this.element : this.queryElements(selector).find(this.containsElement)
29+
const elementWithId = document.getElementById(selector)
30+
if (elementWithId && this.containsElement(elementWithId)) {
31+
return elementWithId
32+
}
33+
const newSelector = this.classifySelector(selector)
34+
return this.element.matches(newSelector) ? this.element : this.queryElements(newSelector).find(this.containsElement)
3035
}
3136

3237
findAllElements(selector: string): Element[] {
38+
const newSelector = this.classifySelector(selector)
3339
return [
34-
...(this.element.matches(selector) ? [this.element] : []),
35-
...this.queryElements(selector).filter(this.containsElement),
40+
...(this.element.matches(newSelector) ? [this.element] : []),
41+
...this.queryElements(newSelector).filter(this.containsElement),
3642
]
3743
}
3844

45+
classifySelector(selector: string | string[]): string {
46+
const tokens = Array.isArray(selector) ? selector : [selector]
47+
48+
const allDefinedTokens = this.getAllClassTokens()
49+
const isDefinedClass = tokens.every((token) => allDefinedTokens.includes(token))
50+
51+
const stringySelector = tokens.join(" ")
52+
return isDefinedClass ? `.${stringySelector.replace(/ /g, ".")}` : stringySelector
53+
}
54+
55+
getAllClassTokens(): string[] {
56+
return Object.entries((this.element as HTMLElement).dataset)
57+
.filter(([key]) => key.endsWith("Class"))
58+
.flatMap(([_, value]) => (value ? value.trim().split(/\s+/) : []))
59+
}
60+
3961
containsElement = (element: Element): boolean => {
4062
return element.closest(this.controllerSelector) === this.element
4163
}

0 commit comments

Comments
 (0)