From 127df5f000489d6b4e1d37c88d9b1d28f370762d Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Tue, 22 Dec 2015 01:34:45 +0100 Subject: [PATCH] Update parser.js --- test/unit/parser.js | 46 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/test/unit/parser.js b/test/unit/parser.js index 48e0c946..6ae176d8 100644 --- a/test/unit/parser.js +++ b/test/unit/parser.js @@ -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);