Current test status: All tests passing (in at least Chrome and Firefox beta)
- Fix (Firefox): tspan (and textPath apparently) have no `getBBox` in Firefox, so recover (fixes FF issue with recalculate test 3: "recalculateDimensions() on text w/tspan with simple translate") - Fix (Chrome): Chrome has a bug in not performing `removeAttribute` after `removeItem`; deal with it (though only if there is a single identity matrix) (fixes Chrome issue with recalculate test 1: " recalculateDimensions() on rect with identity matrix")
This commit is contained in:
@@ -76,6 +76,7 @@ svgedit.recalculate.recalculateDimensions = function (selected) {
|
||||
// remove any unnecessary transforms
|
||||
if (tlist && tlist.numberOfItems > 0) {
|
||||
k = tlist.numberOfItems;
|
||||
var noi = k;
|
||||
while (k--) {
|
||||
var xform = tlist.getItem(k);
|
||||
if (xform.type === 0) {
|
||||
@@ -83,6 +84,14 @@ svgedit.recalculate.recalculateDimensions = function (selected) {
|
||||
// remove identity matrices
|
||||
} else if (xform.type === 1) {
|
||||
if (svgedit.math.isIdentity(xform.matrix)) {
|
||||
if (noi === 1) {
|
||||
// Overcome Chrome bug (though only when noi is 1) with
|
||||
// `removeItem` preventing `removeAttribute` from
|
||||
// subsequently working
|
||||
// See https://bugs.chromium.org/p/chromium/issues/detail?id=843901
|
||||
selected.removeAttribute('transform');
|
||||
return null;
|
||||
}
|
||||
tlist.removeItem(k);
|
||||
}
|
||||
// remove zero-degree rotations
|
||||
@@ -99,9 +108,11 @@ svgedit.recalculate.recalculateDimensions = function (selected) {
|
||||
|
||||
// if this element had no transforms, we are done
|
||||
if (!tlist || tlist.numberOfItems === 0) {
|
||||
// Chrome has a bug that requires clearing the attribute first.
|
||||
// Chrome apparently had a bug that requires clearing the attribute first.
|
||||
selected.setAttribute('transform', '');
|
||||
// However, this still next line currently doesn't work at all in Chrome
|
||||
selected.removeAttribute('transform');
|
||||
// selected.transform.baseVal.clear(); // Didn't help for Chrome bug
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user