-
Notifications
You must be signed in to change notification settings - Fork 154
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
Individual style properties overridden by shorthand properties could be eliminated #512
Comments
First question: is this something that would be considered 'core' functionality, or something that should go into a HtmlProcessor class (presumably Data for CSS shorthand properties available at https://github.com/gilmoreorless/css-shorthand-properties/blob/master/index.js could easily be converted to PHP. |
Let's put it in a separate class. I propose the class name |
Ok. I think some common functionality would need to be shared between If so, for compatibility with non-autoloaders, would it be sufficient to add Also, it seems inefficient to serialize the Emogrified In terms of the actual implementation, I think something like this should work:
I would imagine separate PRs for the various preliminary refactoring before the actual implementation. |
Sorry, I was not clear enough about the Composer dependency. I'll do my best to clear that up now. :-) The Emogrifier class itself should not use any Composer autoloading before Emogrifier 4.0.0 (so that the Emogrifier class could be dropped in any non-Composer project up to version 3.x.y). The other classes can use Composer autoloading. So we could (temporarily) duplicate code into the other classes and then de-duplicate it for version 4.0.0. Yes, allowing to provide and get back the DOMDocument makes sense. We then should allow to create a new $processor = CssMinifier::fromDomDocument($document);
$newHtml = $cssMinifier->collapseAttributes()->render();
$anotherProcessor = CssMinifier::fromHtml($document);
$processedDocument = $anotherProcessor->collapseAttributes()->getDomDocument(); @JakeQZ, @zoliszabo What do you think? |
Presumably then In terms of retro-fitting the pattern of methods |
Exactly. |
We're planning to change the As a first step, we could add a new |
After thinking about it a bit more, I think we should
|
Yes, that would make sense. It would also mean reusable code can be refactored in the new |
Up to including version 3.0.0 (i.e., the last version before 4.0.0). We can keep version 3.0.0 small (mostly to have a release for the breaking changes). |
Now that I've thought about it a bit more, we could mark the Emogrifier class as deprecated in version 3.0.0, and recommend using the new class. Then we could leave the Emogrifier class unchanged after 2.1.0 (except for removing the deprecated methods). |
I am sorry I am bit late to the party.
What about making the old Emogrifier class a simple adapter for CssInliner and we bundle everything into a single big source file via some automated tool? Then each time we make changes to our new classes, we just regenerate the legacy Emogrifier class (bundle file)? I will try to prepare a PR with the above this weekend. What do you guys think? |
Please let's move this discussion to #516. |
Example in #508. When the resultant inline style is something like
margin-top: 0; margin: 1em;
, the individual propertymargin-top: 0
is completely overridden by the shorthandmargin: 1em
and could be eliminated.The text was updated successfully, but these errors were encountered: