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

Fix invalid HTML generated by AnimationDisabler #2498

Merged

Conversation

javierm
Copy link
Contributor

@javierm javierm commented Sep 26, 2021

While I was experimenting with the W3C rspec validations gem, it reported all pages had invalid HTML due to the contents added by Capybara's AnimationDisabler. The W3C Validator was reporting an error:

Element style not allowed as child of element body in this context.

Contexts in which element style may be used:

  • Where metadata content is expected.
  • In a noscript element that is a child of a head element.

Content model for element body:

  • Flow content.

It looks like there can't be any style tags inside the body element.

The <script> part of the markup template remains at the end of the <body> element because it only makes sense if jQuery has already been defined, and jQuery could be defined anywhere inside the <head> or <body> elements.

I'm not familiar with your source code at all, so comments about either the implementation or the tests are much appreciated 🙏.

The W3C Validator was reporting an error:

> Element style not allowed as child of element body in this context.
>
> Contexts in which element style may be used:
>     Where metadata content is expected.
>     In a noscript element that is a child of a head element.
> Content model for element body:
>     Flow content.

It looks like there can't be any <style> tags inside the <body> element
[1].

The <script> part of the markup template remains at the end of the
<body> element because it only makes sense if jQuery has already been
defined, and jQuery could be defined anywhere inside the <head> or
<body> elements.

[1] https://html.spec.whatwg.org/multipage/semantics.html#the-style-element
@twalpole
Copy link
Member

Thanks for this --- While <style> tags are technically illegal outside the element, all modern browsers support it. That said, I don't think it will hurt anything to make it technically legal - just want to think about any possible ramifications for a few days --- If I don't come up with any will merge by end of week

@twalpole twalpole merged commit 5e51607 into teamcapybara:master Oct 3, 2021
@javierm javierm deleted the animation_disabler_invalid_html branch October 3, 2021 14:58
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