Permalink
Browse files

Prevent dom clutter by removing default values for transform and poin…

…ter-events
  • Loading branch information...
1 parent b7bae54 commit 31eec9aa1681ebd9f07c3dcf502e70164c959851 Peter van der Zee committed Dec 7, 2012
Showing with 18 additions and 5 deletions.
  1. +18 −5 src/renderer/svg/svg.js
View
@@ -140,7 +140,16 @@ define([
switch (i) {
case 'interactive':
- el.style.pointerEvents = value ? 'inherit' : 'none';
+ if (value) {
+ // only set if it already contains something
+ // prevents useless "empty" style attrs in dom
+ // (default is inherit anyways)
+ if (el.style.pointerEvents) {
+ el.style.pointerEvents = '';
+ }
+ } else {
+ el.style.pointerEvents = 'none';
+ }
break;
case 'fontFamily':
value = fontIDs[value] || value;
@@ -179,10 +188,14 @@ define([
break;
case 'matrix':
if (value != null) {
- el.setAttribute(
- 'transform',
- matrixToString(value)
- );
+ // clear transform attribute for identity matrix
+ var strMatrix = matrixToString(value);
+ if (strMatrix == 'matrix(1,0,0,1,0,0)') {
+ // this is the default
+ el.removeAttribute('transform');
+ } else {
+ el.setAttribute('transform', strMatrix);
+ }
} else if (value === null) {
el.removeAttribute('transform');
}

0 comments on commit 31eec9a

Please sign in to comment.