Skip to content

Wrongly parses attribute if the preceding attribute is valueless #70

Description

@EATSTEAK

Tried to parse this fragment:

<input id="id" ct="I" readonly value="82.0">

If you try to parse attributes of this input tag, you will find the first letter of the value attribute is omitted.

try this code:

        let dom = tl::parse(r#"<input id="id" ct="I" readonly value="82.0">"#, tl::ParserOptions::new()).unwrap();
        let parser = dom.parser();
        let element = dom
            .get_element_by_id("id")
            .expect("Failed to find element")
            .get(parser)
            .unwrap()
            .as_tag()
            .unwrap();
        element.attributes().iter().for_each(|(key, value)| { println!(r#"{}: {:?}"#, key, value); });

this results:

ct: Some("I")
readonly: None
alue: Some("82.0")
id: Some("id")

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions