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

Support :checked pseudo-class #301

Merged
merged 1 commit into from
Aug 26, 2020
Merged

Conversation

wojtekmach
Copy link
Contributor

Ref: https://developer.mozilla.org/en-US/docs/Web/CSS/:checked

The implementation is slightly relaxed due do differences in handling
checked vs checked="checked' between parsers:

Mochiweb normalizes to {"checked", "checked"}:

iex> Application.put_env(:floki, :html_parser, Floki.HTMLParser.Mochiweb)
iex> ~s{<input type="checkbox" id="a" value="1" checked>} |> Floki.parse_document!()
[{"input", [{"type", "checkbox"}, {"checked", "checked"}], []}]

Neither Hhtml5ever nor FastHtml does:

iex> Application.put_env(:floki, :html_parser, Floki.HTMLParser.Html5ever)
iex> ~s{<input type="checkbox" id="a" value="1" checked>} |> Floki.parse_document!()
[{"input", [{"type", "checkbox"}, {"value", "1"}, {"checked", ""}], []}]

We suport both ways.

Ref: https://developer.mozilla.org/en-US/docs/Web/CSS/:checked

The implementation is slightly relaxed due do differences in handling
`checked` vs `checked="checked'` between parsers:

Mochiweb normalizes to `{"checked", "checked"}`:

    iex> Application.put_env(:floki, :html_parser, Floki.HTMLParser.Mochiweb)
    iex> ~s{<input type="checkbox" id="a" value="1" checked>} |> Floki.parse_document!()
    [{"input", [{"type", "checkbox"}, {"checked", "checked"}], []}]

Neither Hhtml5ever nor FastHtml does:

    iex> Application.put_env(:floki, :html_parser, Floki.HTMLParser.Html5ever)
    iex> ~s{<input type="checkbox" id="a" value="1" checked>} |> Floki.parse_document!()
    [{"input", [{"type", "checkbox"}, {"value", "1"}, {"checked", ""}], []}]

We suport both ways.
@philss
Copy link
Owner

philss commented Aug 26, 2020

@wojtekmach awesome! 😍 Thank you! 💜

@philss philss merged commit 4c0b898 into philss:master Aug 26, 2020
@wojtekmach wojtekmach deleted the wm-checked branch August 26, 2020 14:52
@vnegrisolo vnegrisolo mentioned this pull request Oct 4, 2020
1 task
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

Successfully merging this pull request may close these issues.

2 participants