Implementation details
- Implementation complexity
- DOM building
- ARIA
- Disabling form submission
- Form behavior that’s enabled even without a form element: no change
- Form behavior that’s not disabled: no change
- Nesting: no change
- User-agent stylesheet
- Shadow DOM
- Further considerations
Implementations:
- Chromium (prototype, commits on GitHub)
- WebKit (proof-of-concept, commits on GitHub)
- Firefox in progress (commits in Mercurial)
Implementation complexity
In Chromium:
- Checks for
kSearchTagwhen aliasingdiv: 5 = 2 (parser) + 1 (aria role) + 2 (<p>closing) - Checks for
kSearchTagwhen aliasingform: 10 = 3 (parser) + 1 (aria role) + 2 (<p>closing) + 1 (form) + 3 (collections)
DOM building
- Constraint: The HTMLFormElement class in the 3 major browsers is
finalfor performance. HTMLTreeBuilder(Blink, WebKit):kSearchTaginstantiates an HTMLFormElement.html_tag_names.json5(Blink):name: "search", interfaceName: "HTMLFormElement"generatesHTMLSearchConstructor()->HTMLElementFactory::Create()HTMLTagNames.in(WebKit):search interfaceName=HTMLFormElementgeneratessearchConstructor()->HTMLElementFactory::createKnownElement()(WebKit)
ARIA
role=searchif the element tag issearch, otherwise unchanged (role=formwith an accessible name,role=nonewithout).
Disabling form submission
- HTMLFormElement’s form submit functionality is disabled if the element tag is
searchand theactionattribute is unspecified. - Empty / whitespace-only
action=""attribute resolves to the current page’s address. HTMLFormElement::ScheduleFormSubmission()method returns after handlingmethod=dialog.
Sidenote: if <form> wouldn’t be standardized yet, I’d suggest the same functionality.
Form behavior that’s enabled even without a form element: no change
(Depending on the user agent.)
autocompleteis on by default, defined by the individual form controls:- Validation is defined by the individual form controls.
Form behavior that’s not disabled: no change
<input type=reset>remains functional. It this features is used, this is the developer expectation.- The search element is registered in
document.forms. This is different from<div role=search>, but documented behavior for the<search>element, therefore developers would be aware. This is more intuitive, even. - Form associated elements (form controls) associate with the closest
<form>or<search>ancestor. The presence or absence ofactionhas no effect on association.
Nesting: no change
- For implementation simplicity nesting of
<search>and<form>elements is invalid in any order. <search><search>- it’s semantically not meaningful to put a search component within a search component.
User-agent stylesheet
form, search { display: block; margin-top: 0; }in the user agent stylesheet (Blink:third_party/blink/renderer/core/html/resources/html.css).
Shadow DOM
<search>cannot be a shadow root:.attachShadow()is not allowed (like<form>, but unlike<div>). (MDN)
Further considerations
- Any affected functionality missing?
- Any layout inconsistencies with
<div>?