mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-13 08:13:13 +00:00
Fix some of the parser.js unit tests by making resolveGradients more lenient.
This commit is contained in:
parent
143c251010
commit
ef425d18c5
2 changed files with 15 additions and 20 deletions
12
dist/all.js
vendored
12
dist/all.js
vendored
|
|
@ -2744,7 +2744,10 @@ fabric.util.animate = animate;
|
|||
};
|
||||
|
||||
function resolveGradients(instances) {
|
||||
var ctx = fabric.Element.activeInstance.getContext();
|
||||
var activeInstance = fabric.Element.activeInstance,
|
||||
ctx = activeInstance ? activeInstance.getContext() : null;
|
||||
|
||||
if (!ctx) return;
|
||||
|
||||
for (var i = instances.length; i--; ) {
|
||||
var instanceFillValue = instances[i].get('fill');
|
||||
|
|
@ -2755,12 +2758,7 @@ fabric.util.animate = animate;
|
|||
|
||||
if (fabric.gradientDefs[gradientId]) {
|
||||
instances[i].set('fill',
|
||||
fabric.Gradient.fromElement(
|
||||
fabric.gradientDefs[gradientId],
|
||||
ctx,
|
||||
instances[i]
|
||||
)
|
||||
);
|
||||
fabric.Gradient.fromElement(fabric.gradientDefs[gradientId], ctx, instances[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -287,24 +287,21 @@
|
|||
};
|
||||
|
||||
function resolveGradients(instances) {
|
||||
var ctx = fabric.Element.activeInstance.getContext();
|
||||
|
||||
var activeInstance = fabric.Element.activeInstance,
|
||||
ctx = activeInstance ? activeInstance.getContext() : null;
|
||||
|
||||
if (!ctx) return;
|
||||
|
||||
for (var i = instances.length; i--; ) {
|
||||
var instanceFillValue = instances[i].get('fill');
|
||||
|
||||
|
||||
if (/^url\(/.test(instanceFillValue)) {
|
||||
|
||||
// url(#grad1) --> grad1
|
||||
|
||||
var gradientId = instanceFillValue.slice(5, instanceFillValue.length - 1);
|
||||
|
||||
|
||||
if (fabric.gradientDefs[gradientId]) {
|
||||
instances[i].set('fill',
|
||||
fabric.Gradient.fromElement(
|
||||
fabric.gradientDefs[gradientId],
|
||||
ctx,
|
||||
instances[i]
|
||||
)
|
||||
);
|
||||
instances[i].set('fill',
|
||||
fabric.Gradient.fromElement(fabric.gradientDefs[gradientId], ctx, instances[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue