Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query by #id containing periods do not works #12

Closed
franksouza183 opened this issue Aug 23, 2023 · 2 comments
Closed

Query by #id containing periods do not works #12

franksouza183 opened this issue Aug 23, 2023 · 2 comments

Comments

@franksouza183
Copy link

We can't match when querying by id contains periods:

let html = r#"<div id="foo.bar">baz</div>"#;
let nodes = parse(&html)?;
let selector = Selector::from("#foo.bar");
let element = nodes.query(&selector);

println!("{:?}", element);
// None
@lomirus
Copy link
Owner

lomirus commented Aug 23, 2023

It's as expected, because #foo.bar should be parsed for tags like <div id="foo" class="bar">.

You can try the code below and save it as index.html:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
</head>
<body>
    <div id="foo.bar"></div>
    <script>
      const element = document.querySelector('#foo.bar')
      console.log(element)
    </script>
</body>
</html>

The output should be null in browser.

@franksouza183
Copy link
Author

You're absolutely right. I feel dumb xD, for a brief moment I forgot how css selectors works, this is a case of invalid id attribute of the html file I'm parsing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants