-
Notifications
You must be signed in to change notification settings - Fork 53
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
Copy user styles into dynamic IFRAME
s
#39
Copy user styles into dynamic IFRAME
s
#39
Conversation
Update from JasonBarnabe
Working copy, with test scaffolding in place. Putting it in its own file because it's still a tangle.
Copy user styles into child `IFRAME`s from the containing document.
Remove the IFRAME onLoad() and contentDocument observers.
I don't understand the purpose of the |
Easier for who? Evidently you do understand its purpose. |
Easier as in less code, easier to understand code, and probably quicker code. You'd be able to skip all the code you have to figure out what styles are changing because apply.js's functions already know. |
"Probably quicker"? Not enough to matter. I added eight I'm not gonna refactor the code just to make it more beautiful. Right now it's entirely separable from the rest of the codebase. I suggest that, barring any substantive issues, you leave it that way for at least one release, and add a preference so that you can disable the observers if need be after 1.3.0 is distributed. if (!emergencyStop) observer.observe() If they haven't broken in a year, you can knit the code into 1.4.0. |
Is the purpose of the observer on the |
Yes, no, and no. The style observer watches Stylish add or remove This style observer can't see DOM mutations in the frames. For that you need to start a second style observer on an element in the frame's That gets messy. There can be 2-3 There's an example intra- |
Since |
I've committed a version of this in 908d769 The most significant difference is that I removed the observer for style add/remove and instead changed the logic in apply.js to recursively grab dynamic iframes. I also moved the iframe add/remove observer to apply.js to be able to reuse some of the functions there. |
And is it faster? |
At least it has a bug! |
A fast bug? |
:-) |
One MutationObserver listens for
IFRAME
additions and copies the existingSTYLE.stylish
elements into the new frames. A second MutationObserver listens forSTYLE.stylish
additions and deletions and copiesSTYLE
s or removes existing copies into existing frames.Fixes #3 ; some issues remain.