summaryrefslogtreecommitdiffstats
path: root/src/types
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-12-03 16:19:21 +0100
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-12-03 16:19:21 +0100
commit6d164340d99434b9c11099a2e74d7cf4a4a7e322 (patch)
treec98d3b295f53c58f6affdb62d5df0ee546c29bdf /src/types
parent135f9d03c11a295ff5a9e4bdc4683e8ea35e2f38 (diff)
downloadsvg.js-6d164340d99434b9c11099a2e74d7cf4a4a7e322.tar.gz
svg.js-6d164340d99434b9c11099a2e74d7cf4a4a7e322.zip
fixed methods not returning this and missing methods on List
Diffstat (limited to 'src/types')
-rw-r--r--src/types/List.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/types/List.js b/src/types/List.js
index ccdf11d..44f0fed 100644
--- a/src/types/List.js
+++ b/src/types/List.js
@@ -30,8 +30,17 @@ extend(List, {
}
})
+const reserved = ['toArray', 'constructor', 'each']
+
List.extend = function (methods) {
methods = methods.reduce((obj, name) => {
+ // Don't overwrite own methods
+ if (reserved.includes(name)) return obj
+
+ // Don't add private methods
+ if (name[0] === '_') return obj
+
+ // Relay every call to each()
obj[name] = function (...attrs) {
return this.each(name, ...attrs)
}