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 CSS rendering bug #3

Merged
merged 2 commits into from
Apr 15, 2015
Merged

Fix CSS rendering bug #3

merged 2 commits into from
Apr 15, 2015

Conversation

bgdavidx
Copy link

Fixing the rendering bug that strips out body and head when rendered.

@theycallmeswift
Copy link
Contributor

Hey @bgdavidx! Thanks for the pull. Can you describe the bug in more detail? Specifically steps to recreate would be helpful.

@xavdid
Copy link
Contributor

xavdid commented Apr 13, 2015

The bug was from #2

@bgdavidx
Copy link
Author

Basically, we were competing in the NoLight challenge, everybody who wrote their CSS in <style> tags ended up having it not rendered, effectively having a page with no styling applied. The problem is jQuery.html( ... ) uses an intermediate

element to process the DOM nodes, some browsers such as Chrome automatically remove and tags in a
, and therefore the <style> tag ends up being in and isn't applied to the DOM. I felt this was unfair, told Nick about it, and ended up fixing it using .innerHTML (as innerHTML is JS native and won't strip anything out), and added a script re-evaluator to re-evaluate all scripts since .innerHTML won't run any injected <script> tags automatically. It works if you try the following:

  <!DOCTYPE html>
  <html>
  <head>
  <style>body { background:blue }</style>
  </head>
  <body>
  Helloooooo!
  </body>
  </html>

Try this before and after the change, you'll notice what I'm talking about.

@nquinlan
Copy link

@theycallmeswift, @bgdavidx and I talked about this at HackCU. Thanks again for the fix @bgdavidx!

nquinlan added a commit that referenced this pull request Apr 15, 2015
@nquinlan nquinlan merged commit b4649e5 into MLH:gh-pages Apr 15, 2015
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.

None yet

4 participants