You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Per spec of document.all using construction like <script>document.write(document.all[document.all.length-1].tagName)</script> should write SCRIPT being at that very moment the last element in DOM.
In current Stylus I got the last injected style instead.
It is just another result of DOM injection I've ran into, this time during own JS mischief, hopefully not very probable to occur in real world. Not complaining, just leaving for reference. Looking forward injections will be matter of distant past (again).
How it should look (and how it looks without userstyle OR when page does not link any author stylesheet):
source:
<!DOCTYPE html><title>document.all test</title><linkrel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" /><script>document.write(document.all[document.all.length-1].outerHTML.replace(/</g,'<'))// you should see this script</script>
The text was updated successfully, but these errors were encountered:
I don't think there's anything different we'd do here.
Initially we inject the style within the <head> so there isn't a FOUC. Then after the page loads, we move that style block after the closing body tag (</body>). Doing this increases the style's CSS precedence so you shouldn't have to add an !important flag after every definition.
So, yeah if you have Stylus injecting CSS, the stylesheet(s) will end up as the last element in the document.all list. And I honestly I don't know if and when CSS injection will ever get implemented (see #248).
The last element in DOM !== the last tag in source. You should notice that DOM can be dynamically modified by JS, especially the document root, body, etc.
Per spec of document.all using construction like
<script>document.write(document.all[document.all.length-1].tagName)</script>
should writeSCRIPT
being at that very moment the last element in DOM.In current Stylus I got the last injected style instead.
It is just another result of DOM injection I've ran into, this time during own JS mischief, hopefully not very probable to occur in real world. Not complaining, just leaving for reference. Looking forward injections will be matter of distant past (again).
The text was updated successfully, but these errors were encountered: