mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-01 18:44:42 +00:00
Merge pull request #2256 from asturur/fix-style-parsing
Fix style parsing
This commit is contained in:
commit
d817ae6f63
2 changed files with 12 additions and 1 deletions
|
|
@ -275,7 +275,7 @@
|
|||
*/
|
||||
function parseStyleString(style, oStyle) {
|
||||
var attr, value;
|
||||
style.replace(/;$/, '').split(';').forEach(function (chunk) {
|
||||
style.replace(/;\s*$/, '').split(';').forEach(function (chunk) {
|
||||
var pair = chunk.split(':');
|
||||
|
||||
attr = normalizeAttr(pair[0].trim().toLowerCase());
|
||||
|
|
|
|||
|
|
@ -146,6 +146,17 @@
|
|||
deepEqual(fabric.parseStyleAttribute(element), expectedObject);
|
||||
});
|
||||
|
||||
test('parseStyleAttribute with trailing spaces', function() {
|
||||
var element = fabric.document.createElement('path');
|
||||
element.setAttribute('style', 'left:10px; top:5px; ');
|
||||
|
||||
var expectedObject = {
|
||||
'left': 10,
|
||||
'top': 5
|
||||
};
|
||||
deepEqual(fabric.parseStyleAttribute(element), expectedObject);
|
||||
});
|
||||
|
||||
test('parseStyleAttribute with value normalization', function() {
|
||||
var element = fabric.document.createElement('path');
|
||||
element.setAttribute('style', 'fill:none; stroke-dasharray: 2 0.4;');
|
||||
|
|
|
|||
Loading…
Reference in a new issue