aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorMorgan Harris <gormster@me.com>2021-11-24 11:35:39 +1100
committerMorgan Harris <gormster@me.com>2021-11-24 11:35:39 +1100
commite45843c71c73511ba0f499053184883ddc28f990 (patch)
tree93ad8d3ae854922b7f69eabac5f782cd63628c7f /spec
parent480e5d77e2dcefd6bc4f95a053bb545d9916eb72 (diff)
downloadsvg.js-e45843c71c73511ba0f499053184883ddc28f990.tar.gz
svg.js-e45843c71c73511ba0f499053184883ddc28f990.zip
Allow access to original Array.prototype methods on List prefixed with $
Diffstat (limited to 'spec')
-rw-r--r--spec/spec/types/List.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/spec/types/List.js b/spec/spec/types/List.js
index eb0b40b..9fd27db 100644
--- a/spec/spec/types/List.js
+++ b/spec/spec/types/List.js
@@ -71,6 +71,20 @@ describe('List.js', () => {
delete List.prototype.fooBar
})
+ it('keeps Array prototype names prefixed with $', () => {
+ // We're picking a function that we know isn't part of core svg.js
+ // If we implement an 'unshift' function at some point, change this to something else
+ if (List.prototype.hasOwnProperty('unshift')) {
+ fail('List.unshift is already a function - change this test to use a different name!');
+ return;
+ }
+
+ List.extend([ 'unshift' ])
+ expect(new List().unshift).toEqual(any(Function))
+ expect(new List().$unshift).toEqual(Array.prototype.unshift)
+ delete List.prototype.unshift;
+ });
+
it('skips reserved names', () => {
const { constructor, each, toArray } = List.prototype
List.extend([ 'constructor', 'each', 'toArray' ])