Skip to content

Commit a819280

Browse files
committed
small optimizations
1 parent 4b580dc commit a819280

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

src/svgBaseFix.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,24 @@
2828
var initialHref = attrs[attr];
2929
var parsingNode;
3030

31-
if (initialHref && initialHref.indexOf('#') === 0) {
32-
parsingNode = document.createElement('a')
33-
34-
attrs.$observe(attr, updateValue);
35-
$rootScope.$on('$locationChangeSuccess', updateValue);
36-
37-
function updateValue() {
38-
var newVal;
39-
parsingNode.setAttribute(
40-
'href',
41-
location.pathname + location.search + initialHref
42-
);
43-
newVal = parsingNode.toString();
44-
if (newVal && attrs[attr] !== newVal) {
45-
attrs.$set(attr, newVal);
46-
}
31+
if (!initialHref || initialHref.charAt(0) !== '#') {
32+
return;
33+
}
34+
35+
parsingNode = document.createElement('a');
36+
37+
attrs.$observe(attr, updateValue);
38+
$rootScope.$on('$locationChangeSuccess', updateValue);
39+
40+
function updateValue() {
41+
var newVal;
42+
parsingNode.setAttribute(
43+
'href',
44+
location.pathname + location.search + initialHref
45+
);
46+
newVal = parsingNode.toString();
47+
if (newVal && attrs[attr] !== newVal) {
48+
attrs.$set(attr, newVal);
4749
}
4850
}
4951
}

0 commit comments

Comments
 (0)