Skip to content

Commit

Permalink
Prevent applyTransform when inline style present
Browse files Browse the repository at this point in the history
Ref #1385

With disabled convertStyleToAttrs applyTransform fails to transform
inline styles. They are considered as deoptimisation for now.
Future style manager should fix the problem.
  • Loading branch information
TrySound committed Feb 28, 2021
1 parent 71e4737 commit 79dbb4b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
21 changes: 14 additions & 7 deletions plugins/_path.js
Expand Up @@ -187,13 +187,20 @@ var relative2absolute = exports.relative2absolute = function(data) {
* @return {Array} output path data
*/
exports.applyTransforms = function(elem, path, params) {
// if there are no 'stroke' attr and references to other objects such as
// gradiends or clip-path which are also subjects to transform.
if (!elem.hasAttr('transform') || !elem.attr('transform').value ||
elem.someAttr(function(attr) {
return ~referencesProps.indexOf(attr.name) && ~attr.value.indexOf('url(');
}))
return path;
// if there are no 'stroke' attr and references to other objects such as
// gradiends or clip-path which are also subjects to transform.
if (
!elem.hasAttr('transform') ||
!elem.attr('transform').value ||
// styles are not considered when applying transform
// can be fixed properly with new style engine
elem.hasAttr('style') ||
elem.someAttr((attr) =>
referencesProps.includes(attr.name) && attr.value.includes('url(')
)
) {
return path;
}

var matrix = transformsMultiply(transform2js(elem.attr('transform').value)),
stroke = elem.computedAttr('stroke'),
Expand Down
11 changes: 11 additions & 0 deletions test/plugins/convertPathData.23.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 79dbb4b

Please sign in to comment.