Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 79264c8

Browse files
committed
refactor
1 parent 786f100 commit 79264c8

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/ngSanitize/filter/linky.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -165,18 +165,18 @@ angular.module('ngSanitize').filter('linky', ['$sanitize', function($sanitize) {
165165

166166
function addLink(url, text) {
167167
var key;
168-
var computedAttributes = {};
169168
html.push('<a ');
170169
if (angular.isFunction(attributes)) {
171170
attributes = attributes(url);
172171
}
173172
if (angular.isObject(attributes)) {
174-
computedAttributes = attributes;
175-
for (key in computedAttributes) {
176-
html.push(key + '="' + computedAttributes[key] + '" ');
173+
for (key in attributes) {
174+
html.push(key + '="' + attributes[key] + '" ');
177175
}
176+
} else {
177+
attributes = {};
178178
}
179-
if (angular.isDefined(target) && !('target' in computedAttributes)) {
179+
if (angular.isDefined(target) && !('target' in attributes)) {
180180
html.push('target="',
181181
target,
182182
'" ');

test/ngSanitize/filter/linkySpec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ describe('linky', function() {
8686

8787
it('should strip unsafe attributes', function() {
8888
expect(linky("http://example.com", "_self", {"class" : "blue", "onclick": "alert('Hi')"})).
89-
toEqual('<a target="_self" class="blue" href="http://example.com">http://example.com</a>');
89+
toEqual('<a class="blue" target="_self" href="http://example.com">http://example.com</a>');
9090
});
9191
});
9292
});

0 commit comments

Comments
 (0)