-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deepsweet
committed
Apr 11, 2013
1 parent
3b3275d
commit 9124bf8
Showing
5 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
'use strict'; | ||
|
||
exports.type = 'perItem'; | ||
|
||
exports.active = true; | ||
|
||
/** | ||
* Merge multiple Paths into one. | ||
* | ||
* @param {Object} item current iteration item | ||
* @return {Boolean} if false, item will be filtered out | ||
* | ||
* @author Kir Belevich | ||
*/ | ||
exports.fn = function(item) { | ||
|
||
if (item.isElem() && !item.isEmpty()) { | ||
|
||
var prevContentItem; | ||
|
||
item.content = item.content.filter(function(contentItem) { | ||
|
||
// merge only <path d="...z" /> | ||
if (prevContentItem && | ||
prevContentItem.isElem('path') && | ||
prevContentItem.hasAttr('d') && | ||
Object.keys(prevContentItem.attrs).length === 1 && | ||
prevContentItem.attr('d').value.charAt(prevContentItem.attr('d').value.length - 1) === 'z' && | ||
contentItem.isElem('path') && | ||
contentItem.hasAttr('d') && | ||
Object.keys(contentItem.attrs).length === 1 | ||
) { | ||
prevContentItem.attr('d').value += contentItem.attr('d').value; | ||
|
||
return false; | ||
} | ||
|
||
prevContentItem = contentItem; | ||
|
||
return true; | ||
|
||
}); | ||
} | ||
|
||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.