tl icon indicating copy to clipboard operation
tl copied to clipboard

Wrongly parses attribute if the preceding attribute is valueless

Open EATSTEAK opened this issue 1 year ago • 0 comments

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")

EATSTEAK avatar Aug 30 '24 05:08 EATSTEAK