-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add localStyles plugin, tests and dependencies. #447
Conversation
+1! |
Why there are styles both in attribute and |
I ran npm test which doesn't invoke make travis, so jshint was ommited, As mediaqueries and other nested structures cannot be added to style attribute, Initially the styles element was intended to be preserved by this plugin
What should happen to the class attributes/classe names inside that matched? With best regards |
Just my two cents: It makes sense that this plugin does not remove the style element, considering there is already a plugin that does. You can simply run them in sequence. Optionally, this plugin can perhaps call removeStyleElement, but should be set to false by default. Calling cleanupAttrs afterwards makes sense as well. |
When there are mediaquery styles, the svgo end user would disable removeStyleElement anyway, so this shouldn't cause trouble either. Maybe an extra plugin that just removes styles that aren't used by the classes/ids inside before this one, so there are no leftover styles? |
I added style element clean up which will strip any selectors/rules The following rules apply to style element clean up now:
With best regards P.S.: Maybe later, when it is stable enough, it could be worth it |
Ready to merge? |
I haven't looked into it closely yet. |
There seems to be more issues posted concerning styles in svgo.
To improve selector support, using a XML parser like cheerio would help |
|
||
declarations.forEach(function(declaration) { | ||
declarationAst = { type : 'declaration', | ||
property: declaration.property, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uh-oh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can improve/add comments if necessary. :)
I'm sorry, still don't have much time to look into it. Quite a big pull-request. |
I did a full rewrite and rebranch and will create a new PR instead: #592 |
This PR adds the localStyles plugin which copies styles from style element to style attribute of the selected elements.