-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the <search> element #7320
Add the <search> element #7320
Conversation
Hiiii! ✨ That’s pretty neat—I had no idea this was in the work. I have a couple questions/comments if that’s okay?
I guess where I’m coming at is that if it is not unique per page (unlike Unless I’m missing something? :) |
thanks for the comment, @KittyGiraudel. There is definitely guidance that can be added to flesh that out some more. to quickly answer your questions though:
|
I do think the comparison with IIUC, for both Not sure where that leaves us... |
have some additional content to add. my initial PR got messed up though, so will give it a shot again later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(edited by @domenic) Off-topic: see discussion in #5811 (comment)
I'd like to thank the editors' work on this proposal and their long-term service towards the web developer community. However, [there is a viable alternative](https://github.com//issues/7323) with improved API ergonomy that better serves developer needs, but wasn't considered. In my opinion ignoring that alternative would be a missed opportunity to improve developer satisfaction and the quality of the World Wide Web.Opposition
Since this is a low priority feature, there is no need to rush to a solution without giving due consideration for all needs and use-cases, therefore I have to oppose this proposal in this form at this time. Due to discourtesy and the rejection to discuss the alternative of aliasing <form>
, I've appealed the decisions to the Steering Group. I hope their guidance will help achieve an outcome that serves more developers' needs.
cc @whatwg/html-parser for
Is it OK for new "block" elements to not close If it is, maybe we need to reconsider if |
It would be nice to have |
@artalar I think that would be a separate proposal to hook and redirect the browser's |
@zcorpan Adding the element requires 2 changes to the WebKit & Blink parsers in the HTMLTreeBuilder class: Making it a paragraph closing element requires 2 more trivial changes: OTOH if Note: I don't like the optional |
I agree, and it will be a persistent footgun. I think it's probably better in the long run to change the parser when adding a new block element. |
@hsivonen any updates on your thoughts about whether it's OK to have |
If a |
|
OK I think this is ready now, modulo review of the rendering tests. |
I suggest we let @domenic do the honors since it's been well over a year since we started all this and he might well have some other relevant insights. |
Thank you all for helping push this over the finish line!! I think it's ready to merge. I'll also file an MDN bug. |
Related-to: whatwg/html#7320. Realted-to: whatwg/html#5811.
Related-to: whatwg/html#7320. Realted-to: whatwg/html#5811.
…ment, a=testonly Automatic update from web-platform-tests Add rendering tests for the <search> element See whatwg/html#7320 -- wpt-commits: c49cf0a72fd7278b6f6da0fd19ed37a3d9262bec wpt-pr: 39163
https://bugs.webkit.org/show_bug.cgi?id=254327 rdar://107175819 Reviewed by Tim Nguyen. Adds the new HTML search element as specified in whatwg/html#7320. Given the code changes are minimal there is no preferences guard. It doesn't address the unicode-bidi rendering requirements as they are not addressed for many elements in WebKit: https://bugs.webkit.org/show_bug.cgi?id=256829 This change also syncs most of WPT html/syntax/parsing and adds accessibility test coverage for the main element. * LayoutTests/accessibility/roles-exposed.html: * LayoutTests/imported/w3c/web-platform-tests/html/rendering/non-replaced-elements/flow-content-0/search-styles-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/rendering/non-replaced-elements/flow-content-0/search-styles-iso-8859-8-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/rendering/non-replaced-elements/flow-content-0/search-styles-iso-8859-8.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/rendering/non-replaced-elements/flow-content-0/search-styles.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/rendering/non-replaced-elements/flow-content-0/w3c-import.log: * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/Element.getElementsByTagName-foreign-02.html: * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/README: * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/html-integration-point.html: * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_innerHTML_template-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_innerHTML_template.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_innerHTML_webkit02-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_innerHTML_webkit02.html: * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_search-element.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_search-element_run_type=uri-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_search-element_run_type=write-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_search-element_run_type=write_single-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_tables01.html: * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_tables01_run_type=uri-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_tables01_run_type=write-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_tables01_run_type=write_single-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_template.html: * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_template_run_type=uri-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_template_run_type=write-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_template_run_type=write_single-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_tests20.html: * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_tests20_run_type=uri-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_tests20_run_type=write-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_tests20_run_type=write_single-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_webkit01.html: * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_webkit01_run_type=uri-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_webkit01_run_type=write-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_webkit01_run_type=write_single-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_webkit02.html: * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_webkit02_run_type=uri-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_webkit02_run_type=write-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_webkit02_run_type=write_single-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/math-parse03.html: * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/test.js: (test_fragment): (convert_innerHTML): * LayoutTests/imported/w3c/web-platform-tests/html/syntax/parsing/w3c-import.log: * LayoutTests/inspector/css/shadow-scoped-style-expected.txt: * LayoutTests/platform/mac-wk1/accessibility/roles-exposed-expected.txt: * LayoutTests/platform/mac-wk2/accessibility/roles-exposed-expected.txt: * LayoutTests/tests-options.json: * Source/WebCore/accessibility/AccessibilityNodeObject.cpp: (WebCore::AccessibilityNodeObject::determineAccessibilityRoleFromNode const): * Source/WebCore/css/html.css: (address, article, aside, div, footer, header, hgroup, main, nav, search, section): (address, article, aside, div, footer, header, hgroup, main, nav, section): Deleted. * Source/WebCore/html/HTMLTagNames.in: * Source/WebCore/html/parser/HTMLTreeBuilder.cpp: (WebCore::HTMLTreeBuilder::processStartTagForInBody): (WebCore::HTMLTreeBuilder::processEndTagForInBody): Canonical link: https://commits.webkit.org/264110@main
This was added to the HTML spec here: whatwg/html#7320 I mostly based on this on the webkit patch: WebKit/WebKit#13887 Bug: 1294294 Change-Id: Ia34836f7e5172d862a3a1f24f1e5cbcbb10e6a55 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4767222 Reviewed-by: Mason Freed <masonf@chromium.org> Commit-Queue: Joey Arhar <jarhar@chromium.org> Cr-Commit-Position: refs/heads/main@{#1184358}
Closes #5811.
Mini-explainer
This new element allows authors to express the semantics of "a set of form controls or other content related to performing a search or filtering operation".
This is an especially desired semantic because it is something that an ARIA landmark role exists for (
role="search"
), but today can only be expressed with ARIA. Adding a dedicated element allows authors to follow the first rule of ARIA (~ "don't use ARIA if you can avoid it") and is part of the co-evolution process between ARIA and HTML.Please see the pull request preview for web-developer focused details on usage and examples.
Some notable design choices:
The name. We were initially a bit concerned that developers would think that this was a type of search input, not a search container. Although we briefly discussed alternative names to combat this like
<searcharea>
,<searchform>
,<searchgroup>
,<searchset>
, they each had problems, and a quick Twitter poll helped seal the deal that developers would expect and prefer the name<search>
. (In addition to other developers chiming in with reasoning on the thread.) See the comments starting at Consider creating an HTML search element #5811 (comment) for more details.Like other "block-level" elements,
<search>
closes any open<p>
tags. This ensures an easy transition path from<div role="search">
to<search>
and maintains platform consistency.Like other "block-level" elements, the user-agent stylesheet for
<search>
makes itdisplay: block
andunicode-bidi: isolate
.For conformance-checker purposes, the element is categorized as flow content and palpable content, but not sectioning content. (In this respect, it is categorized similarly to
<main>
, but not like<nav>
or<aside>
.) We are not sure whether this is ideal, partly because due to Suggest adding a warning about outline algorithm #83 sectioning content is a tricky category. But we believe that the main effect of sectioning content is to encourage authors to add headings inside the sections, which is perhaps not the right default here?This element is a straightforward replacement for
<div role="search">
, and does not come with any additional functionality (such as having form-submission capabilities). Instead it can be combined with other primitives such as<form>
, or JavaScript, etc. You can see extensive discussion of this in Consider creating an HTML search element #5811. The reasons for disfavoring more complex solutions are implementer-expressed considerations about complexity and compat risk, as well as web-developer and accessibility community preferences.Credits
The element description and examples is almost entirely written by @scottaohara, although I made a few edits and rearrangements.
PR merge checklist
(See WHATWG Working Mode: Changes for more details.)
/dom.html ( diff )
/grouping-content.html ( diff )
/index.html ( diff )
/indices.html ( diff )
/parsing.html ( diff )
/rendering.html ( diff )
/syntax.html ( diff )