mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-11 23:33:10 +00:00
Update parser.js
This commit is contained in:
parent
280746592c
commit
127df5f000
1 changed files with 46 additions and 0 deletions
|
|
@ -426,6 +426,52 @@
|
|||
}
|
||||
});
|
||||
|
||||
test('fill-opacity attribute with fill attribute', function() {
|
||||
var el = fabric.document.createElement(rect);
|
||||
var opacityValue = Math.random().toFixed(2);
|
||||
|
||||
el.setAttribute('fill-opacity', opacityValue);
|
||||
el.setAttribute('fill', '#FF0000');
|
||||
var obj = fabric.Rect.fromElement(el);
|
||||
|
||||
equal(obj.fill, 'rgba(255,0,0,' + parseFloat(opacityValue) * 255 + ')',
|
||||
'opacity should be parsed correctly from "opacity" attribute of ' + tagNames[i] + ' element');
|
||||
});
|
||||
|
||||
test('fill-opacity attribute without fill attribute', function() {
|
||||
var el = fabric.document.createElement(rect);
|
||||
var opacityValue = Math.random().toFixed(2);
|
||||
|
||||
el.setAttribute('fill-opacity', opacityValue);
|
||||
var obj = fabric.Rect.fromElement(el);
|
||||
|
||||
equal(obj.fill, 'rgba(0,0,0,' + parseFloat(opacityValue) * 255 + ')',
|
||||
'opacity should be parsed correctly from "opacity" attribute of ' + tagNames[i] + ' element');
|
||||
});
|
||||
|
||||
test('stroke-opacity attribute with fill attribute', function() {
|
||||
var el = fabric.document.createElement(rect);
|
||||
var opacityValue = Math.random().toFixed(2);
|
||||
|
||||
el.setAttribute('fill-opacity', opacityValue);
|
||||
el.setAttribute('fill', '#FF0000');
|
||||
var obj = fabric.Rect.fromElement(el);
|
||||
|
||||
equal(obj.fill, 'rgba(255,0,0,' + parseFloat(opacityValue) * 255 + ')',
|
||||
'opacity should be parsed correctly from "opacity" attribute of ' + tagNames[i] + ' element');
|
||||
});
|
||||
|
||||
test('stroke-opacity attribute without fill attribute', function() {
|
||||
var el = fabric.document.createElement(rect);
|
||||
var opacityValue = Math.random().toFixed(2);
|
||||
|
||||
el.setAttribute('fill-opacity', opacityValue);
|
||||
var obj = fabric.Rect.fromElement(el);
|
||||
|
||||
equal(obj.fill, 'rgba(0,0,0,' + parseFloat(opacityValue) * 255 + ')',
|
||||
'opacity should be parsed correctly from "opacity" attribute of ' + tagNames[i] + ' element');
|
||||
});
|
||||
|
||||
test('getCssRule', function() {
|
||||
|
||||
ok(fabric.getCSSRules);
|
||||
|
|
|
|||
Loading…
Reference in a new issue