[whatwg] HTML: A DOM attribute that returns the language of a node
Kang-Hao (Kenny) Lu
kanghaol at oupeng.com
Tue Apr 23 20:08:42 PDT 2013
(13/04/23 16:44), Peter Occil wrote:
> I believe there should be a DOM attribute that returns the language
> of a node, as defined in section 3.2.3.3 "The lang and xml:lang
> attributes".
What's your use case? If you want to style a particular language then
there's the CSS :lang() pseudo-class.
Use cases are important because otherwise I think there are very few
pages with multiple lang attributes...
> While there is a "lang" DOM attribute, it's inadequate because it's
> only affected by the element's "lang" content attribute.
That's true. However, if the case isn't important, we can do tree
traversal (modulo HTTP Content-Language header and pragma) or exhaust
element.matchesSelector(":lang(xxx)").
> Also, I don't see a way to get the "language of a node" otherwise,
> especially since it depends not only on "lang" and "xml:lang", but
> also on the HTTP Content-Language header, which may not be possible
> to retrieve with existing JavaScript methods, as far as I can tell.
Indeed.
Cheers,
Kenny
--
Web Specialist, Opera Sphinx Game Force, Oupeng Browser, Beijing
Try Oupeng: http://www.oupeng.com/
More information about the whatwg
mailing list