decidim-dev 0.7.2 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/decidim/dev/test/rspec_support/capybara.rb +12 -20
- data/lib/decidim/dev/test/rspec_support/phantomjs_polyfills/phantomjs-shim.js +0 -17
- data/lib/decidim/dev/version.rb +1 -1
- metadata +25 -28
- data/lib/decidim/dev/test/rspec_support/phantomjs_polyfills/phantomjs-getOwnPropertyNames.js +0 -16
- data/lib/decidim/dev/test/rspec_support/phantomjs_polyfills/promise.js +0 -233
- data/lib/decidim/dev/test/rspec_support/phantomjs_polyfills/weakmap-polyfill.js +0 -144
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebfa36cbbf9b3dd8dde8ac951c16f4ae6d735ee9505edd92d2ef6b27abfeeb19
|
4
|
+
data.tar.gz: 285db304d2bf8e0769c25a502715f283d79468d58022759b6b36676c74835166
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e630bb11de0c9517dab929c2216f45b4c2f2ff3a98605b38d9e9c0c84aa9abbfd74d13621e70c216f8394aa9b3f27ea835e5a1d12b82005ed85b42c6b506af0
|
7
|
+
data.tar.gz: 6bd84c1375e8857f0b48b2bb6f014936d887ddce78410a232820448ede7197895fa1077c37854f081eed62cd7cb35d9c4ea7892b55cfb123646e7dd04bf0b0cb
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
3
|
+
require "selenium-webdriver"
|
4
4
|
require "capybara-screenshot/rspec"
|
5
5
|
|
6
6
|
module Decidim
|
@@ -21,32 +21,24 @@ module Decidim
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
],
|
31
|
-
js_errors: true,
|
32
|
-
url_whitelist: ["http://*.lvh.me", "localhost", "127.0.0.1"],
|
33
|
-
timeout: 2.minutes
|
34
|
-
}
|
35
|
-
|
36
|
-
Capybara.register_driver :poltergeist do |app|
|
37
|
-
Capybara::Poltergeist::Driver.new(app, capybara_options)
|
38
|
-
end
|
39
|
-
|
40
|
-
Capybara.register_driver :debug do |app|
|
41
|
-
Capybara::Poltergeist::Driver.new(app, capybara_options.merge(inspector: true))
|
24
|
+
Capybara.register_driver :headless_chrome do |app|
|
25
|
+
browser_options = ::Selenium::WebDriver::Chrome::Options.new
|
26
|
+
browser_options.args << "--headless"
|
27
|
+
browser_options.args << "--no-sandbox"
|
28
|
+
browser_options.args << "--window-size=1024,768"
|
29
|
+
Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
|
42
30
|
end
|
43
31
|
|
44
32
|
Capybara::Screenshot.prune_strategy = :keep_last_run
|
45
33
|
Capybara::Screenshot::RSpec.add_link_to_screenshot_for_failed_examples = true
|
46
34
|
|
35
|
+
Capybara::Screenshot.register_driver(:headless_chrome) do |driver, path|
|
36
|
+
driver.browser.save_screenshot(path)
|
37
|
+
end
|
38
|
+
|
47
39
|
Capybara.configure do |config|
|
48
40
|
config.always_include_port = true
|
49
|
-
config.default_driver = :
|
41
|
+
config.default_driver = :headless_chrome
|
50
42
|
end
|
51
43
|
|
52
44
|
RSpec.configure do |config|
|
@@ -86,23 +86,6 @@
|
|
86
86
|
};
|
87
87
|
}());
|
88
88
|
|
89
|
-
/**
|
90
|
-
* Polyfill for CustomEvent
|
91
|
-
* Until PhantomJS v2.0 is out (see https://github.com/ariya/phantomjs/issues/11289)
|
92
|
-
*/
|
93
|
-
(function() {
|
94
|
-
function CustomEvent(event, params) {
|
95
|
-
params = params || { bubbles: false, cancelable: false, detail: undefined };
|
96
|
-
var evt = document.createEvent('CustomEvent');
|
97
|
-
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
|
98
|
-
return evt;
|
99
|
-
};
|
100
|
-
|
101
|
-
CustomEvent.prototype = window.Event.prototype;
|
102
|
-
|
103
|
-
window.CustomEvent = CustomEvent;
|
104
|
-
})();
|
105
|
-
|
106
89
|
/**
|
107
90
|
* Polyfill for String.startsWith
|
108
91
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
|
data/lib/decidim/dev/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decidim-dev
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josep Jaume Rey Peroy
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-11-
|
13
|
+
date: 2017-11-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: decidim
|
@@ -18,14 +18,14 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.7.
|
21
|
+
version: 0.7.3
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - '='
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: 0.7.
|
28
|
+
version: 0.7.3
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: factory_girl_rails
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -167,103 +167,103 @@ dependencies:
|
|
167
167
|
- !ruby/object:Gem::Version
|
168
168
|
version: 0.9.18
|
169
169
|
- !ruby/object:Gem::Dependency
|
170
|
-
name:
|
170
|
+
name: rails-controller-testing
|
171
171
|
requirement: !ruby/object:Gem::Requirement
|
172
172
|
requirements:
|
173
173
|
- - "~>"
|
174
174
|
- !ruby/object:Gem::Version
|
175
|
-
version: '1.
|
175
|
+
version: '1.0'
|
176
176
|
type: :runtime
|
177
177
|
prerelease: false
|
178
178
|
version_requirements: !ruby/object:Gem::Requirement
|
179
179
|
requirements:
|
180
180
|
- - "~>"
|
181
181
|
- !ruby/object:Gem::Version
|
182
|
-
version: '1.
|
182
|
+
version: '1.0'
|
183
183
|
- !ruby/object:Gem::Dependency
|
184
|
-
name:
|
184
|
+
name: rspec-html-matchers
|
185
185
|
requirement: !ruby/object:Gem::Requirement
|
186
186
|
requirements:
|
187
187
|
- - "~>"
|
188
188
|
- !ruby/object:Gem::Version
|
189
|
-
version:
|
189
|
+
version: 0.9.1
|
190
190
|
type: :runtime
|
191
191
|
prerelease: false
|
192
192
|
version_requirements: !ruby/object:Gem::Requirement
|
193
193
|
requirements:
|
194
194
|
- - "~>"
|
195
195
|
- !ruby/object:Gem::Version
|
196
|
-
version:
|
196
|
+
version: 0.9.1
|
197
197
|
- !ruby/object:Gem::Dependency
|
198
|
-
name:
|
198
|
+
name: rubocop
|
199
199
|
requirement: !ruby/object:Gem::Requirement
|
200
200
|
requirements:
|
201
201
|
- - "~>"
|
202
202
|
- !ruby/object:Gem::Version
|
203
|
-
version:
|
203
|
+
version: 0.51.0
|
204
204
|
type: :runtime
|
205
205
|
prerelease: false
|
206
206
|
version_requirements: !ruby/object:Gem::Requirement
|
207
207
|
requirements:
|
208
208
|
- - "~>"
|
209
209
|
- !ruby/object:Gem::Version
|
210
|
-
version:
|
210
|
+
version: 0.51.0
|
211
211
|
- !ruby/object:Gem::Dependency
|
212
|
-
name:
|
212
|
+
name: selenium-webdriver
|
213
213
|
requirement: !ruby/object:Gem::Requirement
|
214
214
|
requirements:
|
215
215
|
- - "~>"
|
216
216
|
- !ruby/object:Gem::Version
|
217
|
-
version:
|
217
|
+
version: '3.7'
|
218
218
|
type: :runtime
|
219
219
|
prerelease: false
|
220
220
|
version_requirements: !ruby/object:Gem::Requirement
|
221
221
|
requirements:
|
222
222
|
- - "~>"
|
223
223
|
- !ruby/object:Gem::Version
|
224
|
-
version:
|
224
|
+
version: '3.7'
|
225
225
|
- !ruby/object:Gem::Dependency
|
226
|
-
name:
|
226
|
+
name: simplecov
|
227
227
|
requirement: !ruby/object:Gem::Requirement
|
228
228
|
requirements:
|
229
229
|
- - "~>"
|
230
230
|
- !ruby/object:Gem::Version
|
231
|
-
version: 0.
|
231
|
+
version: '0.13'
|
232
232
|
type: :runtime
|
233
233
|
prerelease: false
|
234
234
|
version_requirements: !ruby/object:Gem::Requirement
|
235
235
|
requirements:
|
236
236
|
- - "~>"
|
237
237
|
- !ruby/object:Gem::Version
|
238
|
-
version: 0.
|
238
|
+
version: '0.13'
|
239
239
|
- !ruby/object:Gem::Dependency
|
240
|
-
name:
|
240
|
+
name: codecov
|
241
241
|
requirement: !ruby/object:Gem::Requirement
|
242
242
|
requirements:
|
243
243
|
- - "~>"
|
244
244
|
- !ruby/object:Gem::Version
|
245
|
-
version: 0.9
|
245
|
+
version: 0.1.9
|
246
246
|
type: :runtime
|
247
247
|
prerelease: false
|
248
248
|
version_requirements: !ruby/object:Gem::Requirement
|
249
249
|
requirements:
|
250
250
|
- - "~>"
|
251
251
|
- !ruby/object:Gem::Version
|
252
|
-
version: 0.9
|
252
|
+
version: 0.1.9
|
253
253
|
- !ruby/object:Gem::Dependency
|
254
|
-
name:
|
254
|
+
name: db-query-matchers
|
255
255
|
requirement: !ruby/object:Gem::Requirement
|
256
256
|
requirements:
|
257
257
|
- - "~>"
|
258
258
|
- !ruby/object:Gem::Version
|
259
|
-
version: 0.9.
|
259
|
+
version: 0.9.0
|
260
260
|
type: :runtime
|
261
261
|
prerelease: false
|
262
262
|
version_requirements: !ruby/object:Gem::Requirement
|
263
263
|
requirements:
|
264
264
|
- - "~>"
|
265
265
|
- !ruby/object:Gem::Version
|
266
|
-
version: 0.9.
|
266
|
+
version: 0.9.0
|
267
267
|
- !ruby/object:Gem::Dependency
|
268
268
|
name: webmock
|
269
269
|
requirement: !ruby/object:Gem::Requirement
|
@@ -358,10 +358,7 @@ files:
|
|
358
358
|
- lib/decidim/dev/test/rspec_support/geocoder.rb
|
359
359
|
- lib/decidim/dev/test/rspec_support/helpers.rb
|
360
360
|
- lib/decidim/dev/test/rspec_support/html_matchers.rb
|
361
|
-
- lib/decidim/dev/test/rspec_support/phantomjs_polyfills/phantomjs-getOwnPropertyNames.js
|
362
361
|
- lib/decidim/dev/test/rspec_support/phantomjs_polyfills/phantomjs-shim.js
|
363
|
-
- lib/decidim/dev/test/rspec_support/phantomjs_polyfills/promise.js
|
364
|
-
- lib/decidim/dev/test/rspec_support/phantomjs_polyfills/weakmap-polyfill.js
|
365
362
|
- lib/decidim/dev/test/rspec_support/route_helpers.rb
|
366
363
|
- lib/decidim/dev/test/rspec_support/translation_helpers.rb
|
367
364
|
- lib/decidim/dev/test/rspec_support/warden.rb
|
data/lib/decidim/dev/test/rspec_support/phantomjs_polyfills/phantomjs-getOwnPropertyNames.js
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
var hasOwnProperty = Object.hasOwnProperty
|
2
|
-
var originalGetOwnPropertyNames = Object.getOwnPropertyNames
|
3
|
-
function getOwnPropertyNames (obj) {
|
4
|
-
var result = originalGetOwnPropertyNames.call(this, obj)
|
5
|
-
if (typeof obj !== 'function' || hasOwnProperty.call(obj, 'callee')) {
|
6
|
-
return result
|
7
|
-
}
|
8
|
-
return result.filter(function filterCallee (name) {
|
9
|
-
return name !== 'callee' && name !== 'arguments' && name !== 'caller';
|
10
|
-
})
|
11
|
-
};
|
12
|
-
Object.defineProperty(Object, 'getOwnPropertyNames', {
|
13
|
-
value: getOwnPropertyNames,
|
14
|
-
configurable: true,
|
15
|
-
writable: true
|
16
|
-
})
|
@@ -1,233 +0,0 @@
|
|
1
|
-
(function (root) {
|
2
|
-
|
3
|
-
// Store setTimeout reference so promise-polyfill will be unaffected by
|
4
|
-
// other code modifying setTimeout (like sinon.useFakeTimers())
|
5
|
-
var setTimeoutFunc = setTimeout;
|
6
|
-
|
7
|
-
function noop() {}
|
8
|
-
|
9
|
-
// Polyfill for Function.prototype.bind
|
10
|
-
function bind(fn, thisArg) {
|
11
|
-
return function () {
|
12
|
-
fn.apply(thisArg, arguments);
|
13
|
-
};
|
14
|
-
}
|
15
|
-
|
16
|
-
function Promise(fn) {
|
17
|
-
if (typeof this !== 'object') throw new TypeError('Promises must be constructed via new');
|
18
|
-
if (typeof fn !== 'function') throw new TypeError('not a function');
|
19
|
-
this._state = 0;
|
20
|
-
this._handled = false;
|
21
|
-
this._value = undefined;
|
22
|
-
this._deferreds = [];
|
23
|
-
|
24
|
-
doResolve(fn, this);
|
25
|
-
}
|
26
|
-
|
27
|
-
function handle(self, deferred) {
|
28
|
-
while (self._state === 3) {
|
29
|
-
self = self._value;
|
30
|
-
}
|
31
|
-
if (self._state === 0) {
|
32
|
-
self._deferreds.push(deferred);
|
33
|
-
return;
|
34
|
-
}
|
35
|
-
self._handled = true;
|
36
|
-
Promise._immediateFn(function () {
|
37
|
-
var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected;
|
38
|
-
if (cb === null) {
|
39
|
-
(self._state === 1 ? resolve : reject)(deferred.promise, self._value);
|
40
|
-
return;
|
41
|
-
}
|
42
|
-
var ret;
|
43
|
-
try {
|
44
|
-
ret = cb(self._value);
|
45
|
-
} catch (e) {
|
46
|
-
reject(deferred.promise, e);
|
47
|
-
return;
|
48
|
-
}
|
49
|
-
resolve(deferred.promise, ret);
|
50
|
-
});
|
51
|
-
}
|
52
|
-
|
53
|
-
function resolve(self, newValue) {
|
54
|
-
try {
|
55
|
-
// Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure
|
56
|
-
if (newValue === self) throw new TypeError('A promise cannot be resolved with itself.');
|
57
|
-
if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) {
|
58
|
-
var then = newValue.then;
|
59
|
-
if (newValue instanceof Promise) {
|
60
|
-
self._state = 3;
|
61
|
-
self._value = newValue;
|
62
|
-
finale(self);
|
63
|
-
return;
|
64
|
-
} else if (typeof then === 'function') {
|
65
|
-
doResolve(bind(then, newValue), self);
|
66
|
-
return;
|
67
|
-
}
|
68
|
-
}
|
69
|
-
self._state = 1;
|
70
|
-
self._value = newValue;
|
71
|
-
finale(self);
|
72
|
-
} catch (e) {
|
73
|
-
reject(self, e);
|
74
|
-
}
|
75
|
-
}
|
76
|
-
|
77
|
-
function reject(self, newValue) {
|
78
|
-
self._state = 2;
|
79
|
-
self._value = newValue;
|
80
|
-
finale(self);
|
81
|
-
}
|
82
|
-
|
83
|
-
function finale(self) {
|
84
|
-
if (self._state === 2 && self._deferreds.length === 0) {
|
85
|
-
Promise._immediateFn(function() {
|
86
|
-
if (!self._handled) {
|
87
|
-
Promise._unhandledRejectionFn(self._value);
|
88
|
-
}
|
89
|
-
});
|
90
|
-
}
|
91
|
-
|
92
|
-
for (var i = 0, len = self._deferreds.length; i < len; i++) {
|
93
|
-
handle(self, self._deferreds[i]);
|
94
|
-
}
|
95
|
-
self._deferreds = null;
|
96
|
-
}
|
97
|
-
|
98
|
-
function Handler(onFulfilled, onRejected, promise) {
|
99
|
-
this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null;
|
100
|
-
this.onRejected = typeof onRejected === 'function' ? onRejected : null;
|
101
|
-
this.promise = promise;
|
102
|
-
}
|
103
|
-
|
104
|
-
/**
|
105
|
-
* Take a potentially misbehaving resolver function and make sure
|
106
|
-
* onFulfilled and onRejected are only called once.
|
107
|
-
*
|
108
|
-
* Makes no guarantees about asynchrony.
|
109
|
-
*/
|
110
|
-
function doResolve(fn, self) {
|
111
|
-
var done = false;
|
112
|
-
try {
|
113
|
-
fn(function (value) {
|
114
|
-
if (done) return;
|
115
|
-
done = true;
|
116
|
-
resolve(self, value);
|
117
|
-
}, function (reason) {
|
118
|
-
if (done) return;
|
119
|
-
done = true;
|
120
|
-
reject(self, reason);
|
121
|
-
});
|
122
|
-
} catch (ex) {
|
123
|
-
if (done) return;
|
124
|
-
done = true;
|
125
|
-
reject(self, ex);
|
126
|
-
}
|
127
|
-
}
|
128
|
-
|
129
|
-
Promise.prototype['catch'] = function (onRejected) {
|
130
|
-
return this.then(null, onRejected);
|
131
|
-
};
|
132
|
-
|
133
|
-
Promise.prototype.then = function (onFulfilled, onRejected) {
|
134
|
-
var prom = new (this.constructor)(noop);
|
135
|
-
|
136
|
-
handle(this, new Handler(onFulfilled, onRejected, prom));
|
137
|
-
return prom;
|
138
|
-
};
|
139
|
-
|
140
|
-
Promise.all = function (arr) {
|
141
|
-
var args = Array.prototype.slice.call(arr);
|
142
|
-
|
143
|
-
return new Promise(function (resolve, reject) {
|
144
|
-
if (args.length === 0) return resolve([]);
|
145
|
-
var remaining = args.length;
|
146
|
-
|
147
|
-
function res(i, val) {
|
148
|
-
try {
|
149
|
-
if (val && (typeof val === 'object' || typeof val === 'function')) {
|
150
|
-
var then = val.then;
|
151
|
-
if (typeof then === 'function') {
|
152
|
-
then.call(val, function (val) {
|
153
|
-
res(i, val);
|
154
|
-
}, reject);
|
155
|
-
return;
|
156
|
-
}
|
157
|
-
}
|
158
|
-
args[i] = val;
|
159
|
-
if (--remaining === 0) {
|
160
|
-
resolve(args);
|
161
|
-
}
|
162
|
-
} catch (ex) {
|
163
|
-
reject(ex);
|
164
|
-
}
|
165
|
-
}
|
166
|
-
|
167
|
-
for (var i = 0; i < args.length; i++) {
|
168
|
-
res(i, args[i]);
|
169
|
-
}
|
170
|
-
});
|
171
|
-
};
|
172
|
-
|
173
|
-
Promise.resolve = function (value) {
|
174
|
-
if (value && typeof value === 'object' && value.constructor === Promise) {
|
175
|
-
return value;
|
176
|
-
}
|
177
|
-
|
178
|
-
return new Promise(function (resolve) {
|
179
|
-
resolve(value);
|
180
|
-
});
|
181
|
-
};
|
182
|
-
|
183
|
-
Promise.reject = function (value) {
|
184
|
-
return new Promise(function (resolve, reject) {
|
185
|
-
reject(value);
|
186
|
-
});
|
187
|
-
};
|
188
|
-
|
189
|
-
Promise.race = function (values) {
|
190
|
-
return new Promise(function (resolve, reject) {
|
191
|
-
for (var i = 0, len = values.length; i < len; i++) {
|
192
|
-
values[i].then(resolve, reject);
|
193
|
-
}
|
194
|
-
});
|
195
|
-
};
|
196
|
-
|
197
|
-
// Use polyfill for setImmediate for performance gains
|
198
|
-
Promise._immediateFn = (typeof setImmediate === 'function' && function (fn) { setImmediate(fn); }) ||
|
199
|
-
function (fn) {
|
200
|
-
setTimeoutFunc(fn, 0);
|
201
|
-
};
|
202
|
-
|
203
|
-
Promise._unhandledRejectionFn = function _unhandledRejectionFn(err) {
|
204
|
-
if (typeof console !== 'undefined' && console) {
|
205
|
-
console.warn('Possible Unhandled Promise Rejection:', err); // eslint-disable-line no-console
|
206
|
-
}
|
207
|
-
};
|
208
|
-
|
209
|
-
/**
|
210
|
-
* Set the immediate function to execute callbacks
|
211
|
-
* @param fn {function} Function to execute
|
212
|
-
* @deprecated
|
213
|
-
*/
|
214
|
-
Promise._setImmediateFn = function _setImmediateFn(fn) {
|
215
|
-
Promise._immediateFn = fn;
|
216
|
-
};
|
217
|
-
|
218
|
-
/**
|
219
|
-
* Change the function to execute on unhandled rejection
|
220
|
-
* @param {function} fn Function to execute on unhandled rejection
|
221
|
-
* @deprecated
|
222
|
-
*/
|
223
|
-
Promise._setUnhandledRejectionFn = function _setUnhandledRejectionFn(fn) {
|
224
|
-
Promise._unhandledRejectionFn = fn;
|
225
|
-
};
|
226
|
-
|
227
|
-
if (typeof module !== 'undefined' && module.exports) {
|
228
|
-
module.exports = Promise;
|
229
|
-
} else if (!root.Promise) {
|
230
|
-
root.Promise = Promise;
|
231
|
-
}
|
232
|
-
|
233
|
-
})(this);
|
@@ -1,144 +0,0 @@
|
|
1
|
-
/*!
|
2
|
-
* weakmap-polyfill v2.0.0 - ECMAScript6 WeakMap polyfill
|
3
|
-
* https://github.com/polygonplanet/weakmap-polyfill
|
4
|
-
* Copyright (c) 2015-2016 polygon planet <polygon.planet.aqua@gmail.com>
|
5
|
-
* @license MIT
|
6
|
-
*/
|
7
|
-
|
8
|
-
(function(self) {
|
9
|
-
'use strict';
|
10
|
-
|
11
|
-
if (self.WeakMap) {
|
12
|
-
return;
|
13
|
-
}
|
14
|
-
|
15
|
-
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
16
|
-
var defineProperty = function(object, name, value) {
|
17
|
-
if (Object.defineProperty) {
|
18
|
-
Object.defineProperty(object, name, {
|
19
|
-
configurable: true,
|
20
|
-
writable: true,
|
21
|
-
value: value
|
22
|
-
});
|
23
|
-
} else {
|
24
|
-
object[name] = value;
|
25
|
-
}
|
26
|
-
};
|
27
|
-
|
28
|
-
self.WeakMap = (function() {
|
29
|
-
|
30
|
-
// ECMA-262 23.3 WeakMap Objects
|
31
|
-
function WeakMap() {
|
32
|
-
if (this === void 0) {
|
33
|
-
throw new TypeError("Constructor WeakMap requires 'new'");
|
34
|
-
}
|
35
|
-
|
36
|
-
defineProperty(this, '_id', genId('_WeakMap'));
|
37
|
-
|
38
|
-
// ECMA-262 23.3.1.1 WeakMap([iterable])
|
39
|
-
if (arguments.length > 0) {
|
40
|
-
// Currently, WeakMap `iterable` argument is not supported
|
41
|
-
throw new TypeError('WeakMap iterable is not supported');
|
42
|
-
}
|
43
|
-
}
|
44
|
-
|
45
|
-
// ECMA-262 23.3.3.2 WeakMap.prototype.delete(key)
|
46
|
-
defineProperty(WeakMap.prototype, 'delete', function(key) {
|
47
|
-
checkInstance(this, 'delete');
|
48
|
-
|
49
|
-
if (!isObject(key)) {
|
50
|
-
return false;
|
51
|
-
}
|
52
|
-
|
53
|
-
var entry = key[this._id];
|
54
|
-
if (entry && entry[0] === key) {
|
55
|
-
delete key[this._id];
|
56
|
-
return true;
|
57
|
-
}
|
58
|
-
|
59
|
-
return false;
|
60
|
-
});
|
61
|
-
|
62
|
-
// ECMA-262 23.3.3.3 WeakMap.prototype.get(key)
|
63
|
-
defineProperty(WeakMap.prototype, 'get', function(key) {
|
64
|
-
checkInstance(this, 'get');
|
65
|
-
|
66
|
-
if (!isObject(key)) {
|
67
|
-
return void 0;
|
68
|
-
}
|
69
|
-
|
70
|
-
var entry = key[this._id];
|
71
|
-
if (entry && entry[0] === key) {
|
72
|
-
return entry[1];
|
73
|
-
}
|
74
|
-
|
75
|
-
return void 0;
|
76
|
-
});
|
77
|
-
|
78
|
-
// ECMA-262 23.3.3.4 WeakMap.prototype.has(key)
|
79
|
-
defineProperty(WeakMap.prototype, 'has', function(key) {
|
80
|
-
checkInstance(this, 'has');
|
81
|
-
|
82
|
-
if (!isObject(key)) {
|
83
|
-
return false;
|
84
|
-
}
|
85
|
-
|
86
|
-
var entry = key[this._id];
|
87
|
-
if (entry && entry[0] === key) {
|
88
|
-
return true;
|
89
|
-
}
|
90
|
-
|
91
|
-
return false;
|
92
|
-
});
|
93
|
-
|
94
|
-
// ECMA-262 23.3.3.5 WeakMap.prototype.set(key, value)
|
95
|
-
defineProperty(WeakMap.prototype, 'set', function(key, value) {
|
96
|
-
checkInstance(this, 'set');
|
97
|
-
|
98
|
-
if (!isObject(key)) {
|
99
|
-
throw new TypeError('Invalid value used as weak map key');
|
100
|
-
}
|
101
|
-
|
102
|
-
var entry = key[this._id];
|
103
|
-
if (entry && entry[0] === key) {
|
104
|
-
entry[1] = value;
|
105
|
-
return this;
|
106
|
-
}
|
107
|
-
|
108
|
-
defineProperty(key, this._id, [key, value]);
|
109
|
-
return this;
|
110
|
-
});
|
111
|
-
|
112
|
-
|
113
|
-
function checkInstance(x, methodName) {
|
114
|
-
if (!isObject(x) || !hasOwnProperty.call(x, '_id')) {
|
115
|
-
throw new TypeError(
|
116
|
-
methodName + ' method called on incompatible receiver ' +
|
117
|
-
typeof x
|
118
|
-
);
|
119
|
-
}
|
120
|
-
}
|
121
|
-
|
122
|
-
function genId(prefix) {
|
123
|
-
return prefix + '_' + rand() + '.' + rand();
|
124
|
-
}
|
125
|
-
|
126
|
-
function rand() {
|
127
|
-
return Math.random().toString().substring(2);
|
128
|
-
}
|
129
|
-
|
130
|
-
|
131
|
-
defineProperty(WeakMap, '_polyfill', true);
|
132
|
-
return WeakMap;
|
133
|
-
})();
|
134
|
-
|
135
|
-
|
136
|
-
function isObject(x) {
|
137
|
-
return Object(x) === x;
|
138
|
-
}
|
139
|
-
|
140
|
-
})(
|
141
|
-
typeof self !== 'undefined' ? self :
|
142
|
-
typeof window !== 'undefined' ? window :
|
143
|
-
typeof global !== 'undefined' ? global : this
|
144
|
-
);
|