𝗛𝗧𝗠𝗟 𝗷𝘂𝘀𝘁 𝗲𝘃𝗼𝗹𝘃𝗲𝗱 — 𝗮𝗻𝗱 𝗶𝘁’𝘀 𝗳𝗶𝗻𝗮𝗹𝗹𝘆 𝘁𝗮𝗸𝗶𝗻𝗴 𝗯𝗮𝗰𝗸 𝘀𝗼𝗺𝗲 𝗨𝗜 𝗯𝗲𝗵𝗮𝘃𝗶𝗼𝗿 𝗳𝗿𝗼𝗺 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁
Автор: Rohit Luthra
Загружено: 2025-12-15
Просмотров: 50
Описание:
HTML is introducing a 𝗺𝗼𝗿𝗲 𝗱𝗲𝗰𝗹𝗮𝗿𝗮𝘁𝗶𝘃𝗲 𝘄𝗮𝘆 𝘁𝗼 𝗲𝘅𝗽𝗿𝗲𝘀𝘀 𝗨𝗜 𝗮𝗰𝘁𝗶𝗼𝗻𝘀, and browsers are starting to implement it.
Two new attributes are emerging in the HTML spec:
1. command="action" — specifies what action to perform
2. commandfor="id" — targets another element by its id
𝗪𝗵𝘆 𝘁𝗵𝗶𝘀 𝗺𝗮𝘁𝘁𝗲𝗿𝘀
Traditionally, making a button control another element (like opening a menu or dialog) 𝗿𝗲𝗾𝘂𝗶𝗿𝗲𝗱 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁:
• event listeners
• DOM queries
• manual accessibility handling
Even for simple interactions, the code often became verbose and fragile.
With command + commandfor, developers can express interaction logic 𝗱𝗶𝗿𝗲𝗰𝘁𝗹𝘆 𝗶𝗻 𝗛𝗧𝗠𝗟, and the browser:
• performs the action
• manages accessibility attributes (like aria-expanded)
• handles focus and state
This is why many of the ergonomics developers usually rely on frameworks, 𝘄𝗶𝘁𝗵𝗼𝘂𝘁 𝘁𝗵𝗲 𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸 𝗼𝗿 𝗰𝘂𝘀𝘁𝗼𝗺 𝘀𝗰𝗿𝗶𝗽𝘁𝘀.
𝗕𝘂𝗶𝗹𝘁-𝗶𝗻 𝗰𝗼𝗺𝗺𝗮𝗻𝗱𝘀
The command attribute maps to common native behaviors:
• show-popover, hide-popover, toggle-popover → popovers
• show-modal → opens a dialog
• close → closes a dialog
It also replaces older attributes like popovertarget and popovertargetaction with a more 𝗴𝗲𝗻𝗲𝗿𝗮𝗹 𝗮𝗻𝗱 𝗲𝘅𝘁𝗲𝗻𝘀𝗶𝗯𝗹𝗲 𝗔𝗣𝗜.
𝗜𝗺𝗽𝗼𝗿𝘁𝗮𝗻𝘁 𝗿𝗲𝗮𝗹𝗶𝘁𝘆 𝗰𝗵𝗲𝗰𝗸
• This works only for 𝘀𝘁𝗮𝗻𝗱𝗮𝗿𝗱, 𝗯𝘂𝗶𝗹𝘁-𝗶𝗻 𝗰𝗼𝗺𝗺𝗮𝗻𝗱𝘀
• You still need JavaScript for business logic, data, state, and complex flows
• Think of it as 𝗿𝗲𝗺𝗼𝘃𝗶𝗻𝗴 𝗯𝗼𝗶𝗹𝗲𝗿𝗽𝗹𝗮𝘁𝗲, not 𝗿𝗲𝗺𝗼𝘃𝗶𝗻𝗴 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁
𝗧𝗵𝗲 𝗯𝗶𝗴𝗴𝗲𝗿 𝘀𝗶𝗴𝗻𝗮𝗹:
We’re slowly moving from 𝘑𝘚 𝘸𝘪𝘳𝘪𝘯𝘨 𝘦𝘷𝘦𝘳𝘺𝘵𝘩𝘪𝘯𝘨 to 𝘏𝘛𝘔𝘓 𝘦𝘹𝘱𝘳𝘦𝘴𝘴𝘪𝘯𝘨 𝘪𝘯𝘵𝘦𝘯𝘵, and JavaScript focusing on real logic.
Small change.
Big direction shift.
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: