Closed Bug 1213842 Opened 9 years ago Closed 9 years ago

:lang() should not fall back to HTTP headers if empty lang attribute is specified

Categories

(Core :: CSS Parsing and Computation, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla44
Tracking Status
firefox44 --- fixed

People

(Reporter: ayg, Assigned: ayg)

Details

Attachments

(1 file, 2 obsolete files)

If the lang attribute is set on an element to the empty string, the :lang() selector will ignore the lang attribute and fall back to HTTP headers.  This test thinks that behavior is wrong:

http://w3c-test.org/html/dom/elements/global-attributes/the-lang-attribute-009.html

IE and Chrome both pass the test and we fail.

HTML says:

"If the resulting value is the empty string, then it must be interpreted as meaning that the language of the node is explicitly unknown."
https://html.spec.whatwg.org/multipage/dom.html#attr-lang

This is consistent with the behavior of lang="nonempty" on an ancestor, insofar as in the markup

  <x lang="en"><y lang=""></y></x>

the <y> element has a language of "", not "en".  If lang="" were meant to be equivalent to not specifying the language, <y> should have a language of "en" here.

So I think the test/IE/Chrome are right and we should change to match them.
Summary: :lang() should treat lang="" as no language specified for this element → :lang() should not fall back to HTTP headers if empty lang attribute is specified
Comment on attachment 8672605 [details] [diff] [review]
Patch

The patch is broken, new version coming up.
Attachment #8672605 - Attachment is obsolete: true
Attachment #8672605 - Flags: review?(dbaron)
Comment on attachment 8672647 [details] [diff] [review]
Patch v2

Please just return true if hasAttr and return false at the end of the method to indicate whether we found a language, instead of smuggling that information out in the string.
Attachment #8672647 - Flags: review?(bzbarsky) → review-
Comment on attachment 8672697 [details] [diff] [review]
Patch v3

>    * Determing language. Look at the nearest ancestor element that has a lang

While you're here, "Determine", right?

r=me
Attachment #8672697 - Flags: review?(bzbarsky) → review+
https://hg.mozilla.org/mozilla-central/rev/ea52ca27ff99
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla44
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: