servo / html5ever

High-performance browser-grade HTML5 parser
Other
2.11k stars 219 forks source link

Creating attribute not recognized by local_name!() #369

Open kornelski opened 5 years ago

kornelski commented 5 years ago
  1. html5ever v0.22.5 is unaware of the decoding attribute: https://html.spec.whatwg.org/multipage/embedded-content.html#attr-img-decoding

  2. QualName::new(None, ns!(), local_name!("decoding")) doesn't recognize the name. Is there another way to create the attribute?

SimonSapin commented 5 years ago

If an attribute name is mentioned in the HTML spec, it should probably be added to the set of statically-known strings for LocalName so that it can be used with the local_name! macro.

LocalName implements From<&str>.

federicomenaquintero commented 4 years ago

Should the statically-known strings include non-HTML attribute names? For librsvg I need the parse attribute from xinclude. I've been using things like this:

let attr: QualName = ...;

match attr.expanded() {
    expanded_name!("", "href") => ...,
    expanded_name!("", encoding") => ...,
    ref v if *v == ExpandedName { ns: &ns!(), local: &LocalName::from("parse") } => ...,
}

I can submit a PR for those missing names if they are in markup5ever's scope.

jdm commented 4 years ago

I'm inclined to say no, but I'll defer to @SimonSapin here.

SimonSapin commented 4 years ago

I think any name that can commonly appear in a DOM attribute name or element name on web content should be fine to add, especially if it’s defined in a W3C or WHATWG spec. In this specific case, Servo will likely want to implement SVG eventually.

pshaughn commented 4 years ago

"download", "translate", "spellcheck", and "reversed" are other HTML content attributes missing from the list.

noahbald commented 1 day ago

I've also found vector-effect to be missing from the list

jdm commented 1 day ago

PRs to add additional items are accepted. Keep in mind that you can use LocalName::from_str in the meantime.