From 6d164340d99434b9c11099a2e74d7cf4a4a7e322 Mon Sep 17 00:00:00 2001 From: Ulrich-Matthias Schäfer Date: Mon, 3 Dec 2018 16:19:21 +0100 Subject: fixed methods not returning this and missing methods on List --- src/types/List.js | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/types') 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) } -- cgit v1.2.3