ç®æ¬¡
ç®æ¬¡
- ã¯ããã«
<option>
å€æŽæã®ã¯ããŒã³ã«é¢ããæŽçãšææ¡- Option1: ããã©ã«ãã§ã¯ã¯ããŒã³ãããæŽæ°ãããªã¬ãŒããæ¹æ³ãæäŸããïŒå€æŽæ€ç¥ã§ã®ã¯ããŒã³ãOpt-inïŒ
- Option2: åžžã«åæçã«ã¯ããŒã³ããïŒå€æŽæ€ç¥ã§ã®ã¯ããŒã³ãOpt-outïŒ
- Option3: debounceãããŠãåžžã«åæçã«ã¯ããŒã³ããïŒå€æŽæ€ç¥ã§ã®ã¯ããŒã³ãOpt-outïŒ
- Option4: ã¿ãŒã²ããã®DOMå€æŽãè¡ã
- çµè«
ã¯ããã«
Customizable Select Element Ep.16ããã¯ã<selectedcontent>
ã®ã¯ããŒã³å®è£
ã«ããããæè¡çèæ¯ãã話ãããŠããŸãã
2024/12/9æç¹ã§ã®selectã®åããŒãã®å®çŸ©
Ep.19ã§ã¯ãCEReactionsã¿ã€ãã³ã°ã§Nodeå€æŽã®æ€ç¥ãããåé¡ãããåæçãªã¿ã€ãã³ã°ã§Nodeå€æŽã®æ€ç¥ãããæ¹éã«åãæ¿ããããšã䞻匵ãããçµç·¯ãšãcloneNode()
ã®å¶éã«ã€ããŠã話ãããŸããã
ä»åã¯ãäžé£ã®è°è«ã®çµæãçŸç¶ã®<selectedcontent>
ã®ä»æ§ãã©ããªã£ãŠããã®ããã¿ãŠããã<selectedcontent>
ã®æçµãšã³ããªã§ãã
ðð» ãã®æç¹ã§åºãŸã£ãŠããä»æ§
- éžæããã
<option>
ã§ãcloneNode()
ãCallããcloneNode()
ã«ã¯ãããŸããŸãªå¶éãããïŒ<iframe>
ã¯ãªããŒãã«ãªããWCã¯åæ§ç¯ãããã<canvas>
ã¯ã³ããŒãããªããCSSã¢ãã¡ãŒã·ã§ã³ã¯åéãããïŒ
- éžæããã
<option>
ã®åNodeãã¯ããŒã³ãã <selectedcontent>
ãçšããŠã宣èšçãªæ¹æ³ã§ãã¯ããŒã³ãããNodeã<selectedcontent>
ã®Light DOMå ã«è¿œå ãã- éžæããã
<option>
ãå€æŽããããã³ã«ã<selectedcontent>
å ã®DOMãæŽæ°ãã- å€æŽæ€ç¥ã¿ã€ãã³ã°ã®åé¡
- ãã€ã¯ãã¿ã¹ã¯ã¿ã€ãã³ã°ã§å€æŽãæ€ç¥ããïŒ
- CEReactionsã¿ã€ãã³ã°ã§å€æŽãæ€ç¥ããïŒ
- åæçã«å€æŽãæ€ç¥ããïŒ
- å€æŽæ€ç¥ã¿ã€ãã³ã°ã®åé¡
ãNodeã®å€æŽæ€ç¥ã¿ã€ãã³ã°ãã«é¢ããŠã¯ãå
ã蟿ãã°ãã<option>
ã®åNodeãå€æŽãããéãæ€ç¥ãããïŒããªãã®ãïŒããšããOpen UIã§ã®åãããããå§ãŸããŸããã
WHATWGã§ã®è°è«ãé·åŒãå§ããä»ããããããNodeå€æŽæ€ç¥ã®ã¿ã€ãã³ã°ããUAåŽã§ã³ã³ãããŒã«ããå¿ èŠæ§èªäœããçåèŠãããŸãã
<option>
å€æŽæã®ã¯ããŒã³ã«é¢ããæŽçãšææ¡
äžèšã³ã¡ã³ããæããããJakeã¯ãèªèº«ã®ããã°ã§ã<option>
å€æŽæã®ã¯ããŒã³ã¿ã€ãã³ã°ã«é¢ããæŽçãšææ¡ãè¡ããŸããã以éã®Option1~4ã¯ã圌ã®ããã°ãåèã«çè
ããŸãšãããã®ã§ãã
Option1: ããã©ã«ãã§ã¯ã¯ããŒã³ãããæŽæ°ãããªã¬ãŒããæ¹æ³ãæäŸããïŒå€æŽæ€ç¥ã§ã®ã¯ããŒã³ãOpt-inïŒ
ãã®æ¹æ³ã§ã¯ã<option>
ãæ瀺çã«éžæããããšãã§ããã°ã<selectedcontent>
ã«ã¯ããŒã³ãããããã«ãªããŸããããããã®ã¡ã«<option>
ã®åNodeã®DOMãã¹ã¿ã€ã«ãå€æŽãããéã«ã¯ãåã¯ããŒã³ãããâOut-of syncâãªç¶æ
ã«ãªããŸãã
ããã©ã«ãã§ã¯åNodeã®å€æŽãæ€ç¥ããŠã¯ããŒã³ããªãäžã«ãâOut-of syncâãªç¶æ ã«ãªã£ããããšãã£ãŠãåã¯ããŒã³ããæ段ããªãããã§ã¯ãããŸããã
<selectedcontent>
ã«å¯ŸããŠãresetContent()
ãå©çšããããšã§ãAuthoråŽããåã¯ããŒã³ãããªã¬ãŒããããšãã§ããŸãã
ã€ãŸãã<option>
ãæ瀺çã«éžæããããšãããŸãã¯resetContent()
ãåŒã°ãããšãã«ã<selectedcontent>
ãžã®ã¯ããŒã³ãè¡ãããããšã«ãªããŸãã
Option2: åžžã«åæçã«ã¯ããŒã³ããïŒå€æŽæ€ç¥ã§ã®ã¯ããŒã³ãOpt-outïŒ
ãã®æ¹æ³ã§ã¯ã<option>
ã®åNodeãå€æŽããããã³ã«ãåžžã«<selectedcontent>
ã®åNodeãã<option>
ææ°ã®åNodeãcloneNode()
ããçµæã«çœ®ãæããŸãã
<option>
å
ã®å
šãŠã®DOMãã¯ããŒã³ãããããäŸãã°ã<option>
å
éšã®1ã€ã®èŠçŽ ã®å±æ§ãå€æŽããã ãã§ãã<selectedcontent>
å
ã®å
šãŠã®èŠçŽ ãã¯ããŒã³ã§çœ®ãæããããŸãã
ã¯ããŒã³ã¯åæçã«è¡ããããããäºæ³ä»¥äžã«é »ç¹ã«è¡ãããæãããããŸããäŸãã°ãäžèšã®Reactã®äŸã§ã<option>LoadingâŠ</option>
ãã¢ã€ã³ã³ä»ãã®ãªãã·ã§ã³ã«å€æŽãããå Žåã<selectedcontent>
å
ã®å€æŽã¯3åè¡ãããŸãã
<img>
ãæ¿å ¥ãããïŒãã§ã«alt
å±æ§ãèšå®ãããŠããïŒ- ããã¹ããæŽæ°ããã
<img>
ã®src
ãæŽæ°ããã
äŸãã°ã以äžã®ãããªNodeã®å€æŽããã£ããšããŸãããã
ãã®å Žåã<option>
å
ã®åNodeã¯2åã¯ããŒã³ãããŸããèŠçŽ ãappendããã«ã¯ããåé€ãïŒãæ¿å
¥ããšãã2åã®Treeå€æŽãå¿
èŠã ããã§ãã
äŸãã°ã<option>
å
ã®èŠçŽ ã®ã¹ã¿ã€ã«ã10åå€æŽããå Žåãããããã®å€æŽã¯ã¹ã¿ã€ã«å±æ§ãæŽæ°ããããã<selectedcontent>
ã®åNodeã¯10åã¯ããŒã³ã§çœ®ãæããããããšã«ãªããŸãã
ãŸãã<option>
å
ã®èŠçŽ ã§CSS Animationsã䜿çšããå Žåã¯ããã¬ãŒã ããšã«element.style
ãå€æŽãããŸããã€ãŸãã<selectedcontent>
ã®åNodeã¯ããã¬ãŒã ããšã«åæ§ç¯ãããããšã«ãªããŸãã
é床ãªå€æŽæ€ç¥ã ãã§ãªãã<option>
å
ã®åNodeã®å€æŽãã<selectedcontent>
ã®åNodeã«åæ ããããªãå ŽåãèããããŸãã
äŸãã°ã<option>
å
ã®åNodeãšã<selectedcontent>
ã®åNodeã¯ç¬ç«ããèŠçŽ ã§ãããããããããã«ç¬ç«ããã¹ã¿ã€ã«ãåœãŠãããšãã§ããŸãã
ããããäŸãã°ãJavaScriptã䜿ã£ãŠãmouseenter
æã«element.style
ãå€æŽãããšã<selectedcontent>
ã«åæ ãããŠããŸããŸãã<option>
å
ã®åNodeãšã<selectedcontent>
ã®åNodeãç¬ç«ããèŠçŽ ãšããŠæ±ãããå Žåããã®ãããªæåã¯æåŸ
ããªããã®ãšãªãã§ãããã
å ããŠãå°æ¥çã«èµ·ããåé¡ãèããããŸãã
äŸãã°ã<details>
ã¯ãéããç¶æ
ã®æ<details open>
ãšãªãä»æ§ã«ãªã£ãŠããŸããã€ãŸãã<details>
ã¯èªèº«ã®å±æ§ãå€æŽããŸãã
ãããéžæããã<option>
å
ã«ãããããèªèº«ãå€æŽããèŠçŽ ãããå Žåãå€æŽãæ€ç¥ãããã¯ããŒã³ãèµ°ãã<selectedcontent>
å
ã®<details>
ãéãããšã«ãªããŸãã
å ããŠããã®èªåçãªã¯ããŒã³ã¯<option>
ãã<selectedcontent>
ãžã®äžæ¹éè¡ã§ãã
<selectedcontent>
ã§åNodeãå€æŽããããšã«æå³ã¯ãªãã<selectedcontent>
ã§ã®æåã®å€æŽã¯ã<option>
ã®åNodeã次åã¯ããŒã³ããããšãã«äžæžããããŠããŸããŸãã
Option3: debounceãããŠãåžžã«åæçã«ã¯ããŒã³ããïŒå€æŽæ€ç¥ã§ã®ã¯ããŒã³ãOpt-outïŒ
äžèšã®æ¹æ³ãšã»ãšãã©åãã§ããã<option>
ã®åNodeãå€æŽããããšã<selectedcontent>
ã®åNodeã¯ãéåæã®ãã€ã¯ãã¿ã¹ã¯ã¿ã€ãã³ã°ã§cloneNode()
ããçµæã«çœ®ãæãããããšããã«éãããããŸãã
åæã§ã¯ãªããéåæã®ãã€ã¯ãã¿ã¹ã¯ã¿ã€ãã³ã°ã§å€æŽãæ€ç¥ããããšãããã¯ããŒã³ã®åæ°ã倧å¹
ã«æžå°ãããããšãã§ããŸãã
Option2ã§æããäŸãåèã«ãããšã<option>
ã®åNodeã®å€æŽã¯ããã€ã¯ãã¿ã¹ã¯ã¿ã€ãã³ã°ã§ãŸãšããããšãã§ããã¯ããŒã³ã¯1åã®ã¿ãšããããšãã§ããŸãã
ãããããã®æ¹æ³ã«ãåé¡ããããŸãã
ãã®ã»ãã«ããOption2ã§æãã倧åã®åé¡ã¯æ®åããŸãã以äžã®ãããªåé¡ã¯ãOption3ã§ãåŒãç¶ãçºçããããšã«ãªããŸãã
<option>
ã®åNodeãå€æŽããããã³ã«ã<selectedcontent>
ã®å šãŠã®åNodeãã¯ããŒã³ã§çœ®ãæããããããšã«ãªã<option>
å ã®åNodeã®å€æŽãã<selectedcontent>
ã®åNodeã«åæ ãããªãããã«ãããå Žåã«å¯Ÿå¿ã§ããªã- ã¯ããŒã³ã¯
<option>
ãã<selectedcontent>
ãžã®äžæ¹éè¡
Option4: ã¿ãŒã²ããã®DOMå€æŽãè¡ã
UAã<option>
å
ã®ååNodeãšããã«å¯Ÿå¿ããã¯ããŒã³ããªã³ã¯ããŠããæ¹æ³ã§ããå
ã®èŠçŽ ã®å±æ§ãå€æŽãããšããã®ã¯ããŒã³ã®å±æ§ãæŽæ°ããã該åœããã¯ããŒã³ã®å±æ§ã®ã¿ãæŽæ°ãããŸããã€ãŸãã<option>
ã®åNodeãã²ãšã€å€æŽããããã³ã«ã<selectedcontent>
ã®å
šãŠã®åNodeãã¯ããŒã³ã§çœ®ãæããããããšã¯ãªããªããŸãã
æ¿å
¥ãåãã§ãéžæããã<option>
ã«æ°ããèŠçŽ ãæ¿å
¥ããããšããã®èŠçŽ ã¯ã¯ããŒã³ããã<selectedcontent>
å
ã®åçã®äœçœ®ã«æ¿å
¥ãããŸãã
ãã ããã®æ¹æ³ã§ã以äžã®åé¡ã¯æ®ããŸãã
<option>
å ã®åNodeã®å€æŽã<selectedcontent>
ã®åNodeã«åæ ãããªãããã«ãããå Žåã«å¯Ÿå¿ã§ããªã- ã¯ããŒã³ã¯
<option>
ãã<selectedcontent>
ãžã®äžæ¹éè¡- â» ãšã¯ãããäžæ¹éè¡ã®ãã©ãŒãªã³ã°ã®æåã¯ãâ¡ãâ¢ãšã¯ç°ãªããã¯ããŒã³ãªãã·ã§ã³ã§ã¯ãéžæããã
<option>
ã®å€æŽã¯ã<selectedcontent>
å ã®ã³ã³ãã³ããããªã»ãããããããããã³ã³ãã³ããå®å šã«æ°ããã¯ããŒã³ã§çœ®ãæããããŸããäžæ¹ããã®ãªãã·ã§ã³ã§ã¯ãDOMã®å€æŽãtargetã«ãªã£ãŠããããã<selectedcontent>
ã®ã³ã³ãã³ããæåã§å€æŽãããšããããã©ãŒã¯ã®ãããªãã®ã«ãªããŸãã
- â» ãšã¯ãããäžæ¹éè¡ã®ãã©ãŒãªã³ã°ã®æåã¯ãâ¡ãâ¢ãšã¯ç°ãªããã¯ããŒã³ãªãã·ã§ã³ã§ã¯ãéžæããã
äŸãã°ãã¯ããŒã³èŠçŽ ã®æ¿å
¥ã¯ãUAã§ã¯element.insertBefore
ã䜿çšããŠå®è£
ãããŸããåç
§ããŠããç¹å®ã®Nodeã®åã«æ°ããªã¯ããŒã³ãæ¿å
¥ããã«ããã£ãŠã<selectedcontent>
ã®å
容ãAuthoråŽã§å€æŽãããŠããŸããšãUAåŽã§ã¯ããŒã³ã®æ¿å
¥ã倱æããæãããããŸãã
çµè«
Open UIã§ã®è°è«ã®çµæãæçµçã«ã¯Option1ãæ¡çšãããããšã«ãªãããããã©ã«ãã§ã¯åNodeã®æŽæ°ãæ€ç¥ããŠã¯ããŒã³ãããresetContent()
ãªã©ã®ãæŽæ°ãããªã¬ãŒããæ¹æ³ãæäŸãããæ¹éãæ¡çšãããŸããã
RESOLVED: dont observe mutations in option elements. only clone into selectedoption during parsing and when a new option becomes selected
ã€ãŸããçŸç¶ã®<selectedcontent>
ã¯ä»¥äžã®ãããªæ«å®ä»æ§ã«ãªã£ãŠãããšèšããŸãã
ðð» ãã®æç¹ã§åºãŸã£ãŠããä»æ§
- éžæããã
<option>
ã§ãcloneNode()
ãCallããcloneNode()
ã«ã¯ãããŸããŸãªå¶éãããïŒ<iframe>
ã¯ãªããŒãã«ãªããWCã¯åæ§ç¯ãããã<canvas>
ã¯ã³ããŒãããªããCSSã¢ãã¡ãŒã·ã§ã³ã¯åéãããïŒ- â çè ã®èŠ³æž¬ç¯å²ã§ã¯ãè°è«ã¯ãã®ã³ã¡ã³ãã§æ¢ãŸã£ãŠãã
- ãããããAllow slotting indirect childrenã®çµæã«å·Šå³ãããã®ã§ãè°è«éäž
- éžæããã
<option>
ã®åNodeãã¯ããŒã³ãã <selectedcontent>
ãçšããŠã宣èšçãªæ¹æ³ã§ãã¯ããŒã³ãããNodeã<selectedcontent>
ã®Light DOMå ã«è¿œå ãã- éžæããã
<option>
ãå€æŽããããã³ã«ã<selectedcontent>
å ã®DOMã¯æŽæ°ããªã - 代ããã«ãAuthorãæ瀺çã«
resetContent()
ãªã©ãåŒã³åºãããšã§ã<selectedcontent>
å ã®DOMãæŽæ°ã§ãã
cloneNode()
ã®å¶éã®ä»¶ãªã©ãæªã ã«<selectedcontent>
ã®ä»æ§ã¯çå®äžã§ãããããããéžæããã<option>
ã®åNodeã®<selectedcontent>
ãžã®ã¯ããŒã³ã¿ã€ãã³ã°ãã«é¢ããŠã¯ãé·ãè°è«ãçµãŠããããèœã¡çãçµè«ãšãªããŸããã
次åã¯ãEp.1~Ep.19ãŸã§ã§è¿œã£ãŠããCSEã®çŸç¶ããŸãšããŸãã
ããã§ã¯ããŸãææ¥â
See you tomorrow!
Appendix
- select: Should
<selectedoption>
respond to mutations in the selected<option>
· Issue #825 · openui/open-ui - Add
<selectedcontent>
element by josepharhar · Pull Request #528 · w3c/html-aria - Define the
<selectedcontent>
element by josepharhar · Pull Request #10633 · whatwg/html - [html-aam] Addition: selectedoption element by scottaohara · Pull Request #2344 · w3c/aria
- 5370555: Implement for StylableSelect
Standard Positions