Skip to content

Fix undefined sheet of SVGStyleElement in Safari#159

Merged
knuhol merged 3 commits intocburgmer:masterfrom
knuhol:master
Oct 12, 2016
Merged

Fix undefined sheet of SVGStyleElement in Safari#159
knuhol merged 3 commits intocburgmer:masterfrom
knuhol:master

Conversation

@knuhol
Copy link
Collaborator

@knuhol knuhol commented Oct 12, 2016

Fix of issue #158

var selectorRegex = matchingSimpleSelectorsRegex(simpleSelectorList);

asArray(element.querySelectorAll('style')).forEach(function (styleElement) {
if (typeof styleElement.sheet === 'undefined') {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've taken up the habit of commenting on the workarounds that go into the library. It hopefully reduces the amount of "WTF" folks will have when reading this later. Especially considering that this library feels like a one big workaround.
Feel free to do the same, possibly linking to our discussion on the issue tracker.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it is a good idea, I did it.

@cburgmer
Copy link
Owner

I forgot. One thing that helps me (and hopefully others) maintain this project, is making sure all the pieces that make it into the code base have at least a test that documents why this is there.

For the case we are discussing here, having one test, say, in https://github.com/akarienta/rasterizeHTML.js/blob/5c1be68cc899ea9aebc54ed46165650b8e95a648/test/specs/DocumentUtilSpec.js#L13 to make sure style elements inside SVG don't blow up, would help guarding against later breaks. I'd suggest adding one.

You can run the test in Safari by opening the test/SpecRunner.html.

Apologies for the number of failing tests, I started developing a new feature a while ago that hasn't been wrapped up yet. I'll try to clean this up.

@cburgmer
Copy link
Owner

I've read a nice post about opening up access for contributors early on. So you should be getting a notification on getting access. Feel free to merge this PR yourself.

I'll try to get a release going afterwards.

@knuhol
Copy link
Collaborator Author

knuhol commented Oct 12, 2016

Thanks to the added spec I've discovered a problem with my fix, it should be all right now. I think it can be merged :) Thanks for the rights!

@knuhol knuhol merged commit 69a309e into cburgmer:master Oct 12, 2016
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