ember-source 2.17.0.beta.4 → 2.17.0.beta.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/dist/ember-runtime.js +319 -230
- data/dist/ember-template-compiler.js +323 -249
- data/dist/ember-testing.js +1 -1
- data/dist/ember-tests.js +80 -18
- data/dist/ember-tests.prod.js +80 -18
- data/dist/ember.debug.js +329 -238
- data/dist/ember.min.js +146 -147
- data/dist/ember.prod.js +156 -154
- data/package.json +14 -13
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8db7c51ac4f81fcb3621cf22fd9440340c9915a1b5c0c5363adbd729f29e606f
|
4
|
+
data.tar.gz: 8a9c2e3b2b27d0c9ee95a19f731dfc0e557a5abcc3c497371780c7a76cace422
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb410d9a8ee421a728ad50ad2a0e76f3fac57890364e438f0fa73930356a116c0c091e2a2cc40f01294f7be8776fd5ea8cac63bcd1c7cdda44ca4bc2d9f08395
|
7
|
+
data.tar.gz: 46b1e4aa61a60c7f8e2d77e4ddd1d6b73bc17c0881ae4e1f9b4374e9555dc4c71edb5dcbbd785d70cbbea875426b6b253aae8fd9c3822be16546cfd0f87105ee
|
data/dist/ember-runtime.js
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
* Portions Copyright 2008-2011 Apple Inc. All rights reserved.
|
7
7
|
* @license Licensed under MIT license
|
8
8
|
* See https://raw.github.com/emberjs/ember.js/master/LICENSE
|
9
|
-
* @version 2.17.0-beta.
|
9
|
+
* @version 2.17.0-beta.5
|
10
10
|
*/
|
11
11
|
|
12
12
|
var enifed, requireModule, Ember;
|
@@ -1989,6 +1989,146 @@ enifed('ember-metal', ['exports', 'ember-environment', 'ember-utils', 'ember-deb
|
|
1989
1989
|
return ObserverSet;
|
1990
1990
|
}();
|
1991
1991
|
|
1992
|
+
/**
|
1993
|
+
@module ember
|
1994
|
+
*/
|
1995
|
+
var id = 0;
|
1996
|
+
|
1997
|
+
// Returns whether Type(value) is Object according to the terminology in the spec
|
1998
|
+
function isObject$1(value) {
|
1999
|
+
return typeof value === 'object' && value !== null || typeof value === 'function';
|
2000
|
+
}
|
2001
|
+
|
2002
|
+
/*
|
2003
|
+
* @class Ember.WeakMap
|
2004
|
+
* @public
|
2005
|
+
* @category ember-metal-weakmap
|
2006
|
+
*
|
2007
|
+
* A partial polyfill for [WeakMap](http://www.ecma-international.org/ecma-262/6.0/#sec-weakmap-objects).
|
2008
|
+
*
|
2009
|
+
* There is a small but important caveat. This implementation assumes that the
|
2010
|
+
* weak map will live longer (in the sense of garbage collection) than all of its
|
2011
|
+
* keys, otherwise it is possible to leak the values stored in the weak map. In
|
2012
|
+
* practice, most use cases satisfy this limitation which is why it is included
|
2013
|
+
* in ember-metal.
|
2014
|
+
*/
|
2015
|
+
var WeakMapPolyfill = function () {
|
2016
|
+
function WeakMapPolyfill(iterable) {
|
2017
|
+
emberBabel.classCallCheck(this, WeakMapPolyfill);
|
2018
|
+
|
2019
|
+
this._id = emberUtils.GUID_KEY + id++;
|
2020
|
+
|
2021
|
+
if (iterable === null || iterable === undefined) {
|
2022
|
+
return;
|
2023
|
+
} else if (Array.isArray(iterable)) {
|
2024
|
+
for (var i = 0; i < iterable.length; i++) {
|
2025
|
+
var _iterable$i = iterable[i],
|
2026
|
+
key = _iterable$i[0],
|
2027
|
+
value = _iterable$i[1];
|
2028
|
+
|
2029
|
+
this.set(key, value);
|
2030
|
+
}
|
2031
|
+
} else {
|
2032
|
+
throw new TypeError('The weak map constructor polyfill only supports an array argument');
|
2033
|
+
}
|
2034
|
+
}
|
2035
|
+
|
2036
|
+
/*
|
2037
|
+
* @method get
|
2038
|
+
* @param key {Object | Function}
|
2039
|
+
* @return {Any} stored value
|
2040
|
+
*/
|
2041
|
+
|
2042
|
+
WeakMapPolyfill.prototype.get = function get(obj) {
|
2043
|
+
if (!isObject$1(obj)) {
|
2044
|
+
return undefined;
|
2045
|
+
}
|
2046
|
+
|
2047
|
+
var meta$$1 = exports.peekMeta(obj);
|
2048
|
+
if (meta$$1 !== undefined) {
|
2049
|
+
var map = meta$$1.readableWeak();
|
2050
|
+
if (map !== undefined) {
|
2051
|
+
var val = map[this._id];
|
2052
|
+
if (val === UNDEFINED) {
|
2053
|
+
return undefined;
|
2054
|
+
}
|
2055
|
+
return val;
|
2056
|
+
}
|
2057
|
+
}
|
2058
|
+
};
|
2059
|
+
|
2060
|
+
/*
|
2061
|
+
* @method set
|
2062
|
+
* @param key {Object | Function}
|
2063
|
+
* @param value {Any}
|
2064
|
+
* @return {WeakMap} the weak map
|
2065
|
+
*/
|
2066
|
+
|
2067
|
+
WeakMapPolyfill.prototype.set = function set(obj, value) {
|
2068
|
+
if (!isObject$1(obj)) {
|
2069
|
+
throw new TypeError('Invalid value used as weak map key');
|
2070
|
+
}
|
2071
|
+
|
2072
|
+
if (value === undefined) {
|
2073
|
+
value = UNDEFINED;
|
2074
|
+
}
|
2075
|
+
|
2076
|
+
meta(obj).writableWeak()[this._id] = value;
|
2077
|
+
|
2078
|
+
return this;
|
2079
|
+
};
|
2080
|
+
|
2081
|
+
/*
|
2082
|
+
* @method has
|
2083
|
+
* @param key {Object | Function}
|
2084
|
+
* @return {boolean} if the key exists
|
2085
|
+
*/
|
2086
|
+
|
2087
|
+
WeakMapPolyfill.prototype.has = function has(obj) {
|
2088
|
+
if (!isObject$1(obj)) {
|
2089
|
+
return false;
|
2090
|
+
}
|
2091
|
+
|
2092
|
+
var meta$$1 = exports.peekMeta(obj);
|
2093
|
+
if (meta$$1 !== undefined) {
|
2094
|
+
var map = meta$$1.readableWeak();
|
2095
|
+
if (map !== undefined) {
|
2096
|
+
return map[this._id] !== undefined;
|
2097
|
+
}
|
2098
|
+
}
|
2099
|
+
|
2100
|
+
return false;
|
2101
|
+
};
|
2102
|
+
|
2103
|
+
/*
|
2104
|
+
* @method delete
|
2105
|
+
* @param key {Object | Function}
|
2106
|
+
* @return {boolean} if the key was deleted
|
2107
|
+
*/
|
2108
|
+
|
2109
|
+
WeakMapPolyfill.prototype.delete = function _delete(obj) {
|
2110
|
+
if (this.has(obj)) {
|
2111
|
+
delete exports.peekMeta(obj).writableWeak()[this._id];
|
2112
|
+
return true;
|
2113
|
+
} else {
|
2114
|
+
return false;
|
2115
|
+
}
|
2116
|
+
};
|
2117
|
+
|
2118
|
+
/*
|
2119
|
+
* @method toString
|
2120
|
+
* @return {String}
|
2121
|
+
*/
|
2122
|
+
|
2123
|
+
WeakMapPolyfill.prototype.toString = function toString$$1() {
|
2124
|
+
return '[object WeakMap]';
|
2125
|
+
};
|
2126
|
+
|
2127
|
+
return WeakMapPolyfill;
|
2128
|
+
}();
|
2129
|
+
|
2130
|
+
var WeakMap$1 = emberUtils.HAS_NATIVE_WEAKMAP ? WeakMap : WeakMapPolyfill;
|
2131
|
+
|
1992
2132
|
exports.runInTransaction = void 0;
|
1993
2133
|
exports.didRender = void 0;
|
1994
2134
|
exports.assertNotRendered = void 0;
|
@@ -1996,80 +2136,200 @@ enifed('ember-metal', ['exports', 'ember-environment', 'ember-utils', 'ember-deb
|
|
1996
2136
|
// detect-backtracking-rerender by default is debug build only
|
1997
2137
|
// detect-glimmer-allow-backtracking-rerender can be enabled in custom builds
|
1998
2138
|
if (ember_features.EMBER_GLIMMER_DETECT_BACKTRACKING_RERENDER || ember_features.EMBER_GLIMMER_ALLOW_BACKTRACKING_RERENDER) {
|
1999
|
-
var counter = 0;
|
2000
|
-
var inTransaction = false;
|
2001
|
-
var shouldReflush = void 0;
|
2002
|
-
var debugStack = void 0;
|
2003
2139
|
|
2004
|
-
|
2005
|
-
shouldReflush = false;
|
2006
|
-
inTransaction = true;
|
2007
|
-
{
|
2008
|
-
debugStack = context$$1.env.debugStack;
|
2009
|
-
}
|
2010
|
-
context$$1[methodName]();
|
2011
|
-
inTransaction = false;
|
2012
|
-
counter++;
|
2013
|
-
return shouldReflush;
|
2014
|
-
};
|
2140
|
+
// there are 4 states
|
2015
2141
|
|
2016
|
-
|
2017
|
-
|
2018
|
-
|
2019
|
-
}
|
2020
|
-
var meta$$1 = meta(object);
|
2021
|
-
var lastRendered = meta$$1.writableLastRendered();
|
2022
|
-
lastRendered[key] = counter;
|
2142
|
+
// NATIVE WEAKMAP AND DEBUG
|
2143
|
+
// tracks lastRef and lastRenderedIn per rendered object and key during a transaction
|
2144
|
+
// release everything via normal weakmap semantics by just derefencing the weakmap
|
2023
2145
|
|
2024
|
-
|
2025
|
-
|
2026
|
-
|
2146
|
+
// NATIVE WEAKMAP AND RELEASE
|
2147
|
+
// tracks transactionId per rendered object and key during a transaction
|
2148
|
+
// release everything via normal weakmap semantics by just derefencing the weakmap
|
2149
|
+
|
2150
|
+
// WEAKMAP POLYFILL AND DEBUG
|
2151
|
+
// tracks lastRef and lastRenderedIn per rendered object and key during a transaction
|
2152
|
+
// since lastRef retains a lot of app state (will have a ref to the Container)
|
2153
|
+
// if the object rendered is retained (like a immutable POJO in module state)
|
2154
|
+
// during acceptance tests this adds up and obfuscates finding other leaks.
|
2155
|
+
|
2156
|
+
// WEAKMAP POLYFILL AND RELEASE
|
2157
|
+
// tracks transactionId per rendered object and key during a transaction
|
2158
|
+
// leaks it because small and likely not worth tracking it since it will only
|
2159
|
+
// be leaked if the object is retained
|
2027
2160
|
|
2028
|
-
|
2029
|
-
|
2030
|
-
|
2161
|
+
var TransactionRunner = function () {
|
2162
|
+
function TransactionRunner() {
|
2163
|
+
emberBabel.classCallCheck(this, TransactionRunner);
|
2164
|
+
|
2165
|
+
this.transactionId = 0;
|
2166
|
+
this.inTransaction = false;
|
2167
|
+
this.shouldReflush = false;
|
2168
|
+
this.weakMap = new WeakMap$1();
|
2169
|
+
{
|
2170
|
+
// track templates
|
2171
|
+
this.debugStack = undefined;
|
2172
|
+
|
2173
|
+
if (!emberUtils.HAS_NATIVE_WEAKMAP) {
|
2174
|
+
// DEBUG AND POLYFILL
|
2175
|
+
// needs obj tracking
|
2176
|
+
this.objs = [];
|
2177
|
+
}
|
2031
2178
|
}
|
2032
2179
|
}
|
2033
|
-
};
|
2034
2180
|
|
2035
|
-
|
2036
|
-
|
2037
|
-
|
2181
|
+
TransactionRunner.prototype.runInTransaction = function runInTransaction(context$$1, methodName) {
|
2182
|
+
this.before(context$$1);
|
2183
|
+
try {
|
2184
|
+
context$$1[methodName]();
|
2185
|
+
} finally {
|
2186
|
+
this.after();
|
2187
|
+
}
|
2188
|
+
return this.shouldReflush;
|
2189
|
+
};
|
2038
2190
|
|
2039
|
-
|
2191
|
+
TransactionRunner.prototype.didRender = function didRender(object, key, reference) {
|
2192
|
+
if (!this.inTransaction) {
|
2193
|
+
return;
|
2194
|
+
}
|
2040
2195
|
{
|
2041
|
-
|
2042
|
-
|
2043
|
-
|
2044
|
-
|
2045
|
-
|
2046
|
-
|
2047
|
-
|
2048
|
-
|
2049
|
-
|
2050
|
-
|
2051
|
-
|
2052
|
-
|
2053
|
-
|
2196
|
+
this.setKey(object, key, {
|
2197
|
+
lastRef: reference,
|
2198
|
+
lastRenderedIn: this.debugStack.peek()
|
2199
|
+
});
|
2200
|
+
}
|
2201
|
+
};
|
2202
|
+
|
2203
|
+
TransactionRunner.prototype.assertNotRendered = function assertNotRendered(object, key) {
|
2204
|
+
if (!this.inTransaction) {
|
2205
|
+
return;
|
2206
|
+
}
|
2207
|
+
if (this.hasRendered(object, key)) {
|
2208
|
+
{
|
2209
|
+
var _getKey = this.getKey(object, key),
|
2210
|
+
lastRef = _getKey.lastRef,
|
2211
|
+
lastRenderedIn = _getKey.lastRenderedIn;
|
2212
|
+
|
2213
|
+
var currentlyIn = this.debugStack.peek();
|
2214
|
+
|
2215
|
+
var parts = [];
|
2216
|
+
var label = void 0;
|
2217
|
+
|
2218
|
+
if (lastRef !== undefined) {
|
2219
|
+
while (lastRef && lastRef._propertyKey) {
|
2220
|
+
parts.unshift(lastRef._propertyKey);
|
2221
|
+
lastRef = lastRef._parentReference;
|
2222
|
+
}
|
2223
|
+
|
2224
|
+
label = parts.join('.');
|
2225
|
+
} else {
|
2226
|
+
label = 'the same value';
|
2054
2227
|
}
|
2055
2228
|
|
2056
|
-
|
2057
|
-
|
2058
|
-
|
2229
|
+
var message = 'You modified "' + label + '" twice on ' + object + ' in a single render. It was rendered in ' + lastRenderedIn + ' and modified in ' + currentlyIn + '. This was unreliable and slow in Ember 1.x and';
|
2230
|
+
|
2231
|
+
if (ember_features.EMBER_GLIMMER_ALLOW_BACKTRACKING_RERENDER) {
|
2232
|
+
true && !false && emberDebug.deprecate(message + ' will be removed in Ember 3.0.', false, { id: 'ember-views.render-double-modify', until: '3.0.0' });
|
2233
|
+
} else {
|
2234
|
+
true && !false && emberDebug.assert(message + ' is no longer supported. See https://github.com/emberjs/ember.js/issues/13948 for more details.', false);
|
2235
|
+
}
|
2059
2236
|
}
|
2060
2237
|
|
2061
|
-
|
2238
|
+
this.shouldReflush = true;
|
2239
|
+
}
|
2240
|
+
};
|
2062
2241
|
|
2063
|
-
|
2064
|
-
|
2065
|
-
|
2066
|
-
|
2242
|
+
TransactionRunner.prototype.hasRendered = function hasRendered(object, key) {
|
2243
|
+
if (!this.inTransaction) {
|
2244
|
+
return false;
|
2245
|
+
}
|
2246
|
+
{
|
2247
|
+
return this.getKey(object, key) !== undefined;
|
2248
|
+
}
|
2249
|
+
return this.getKey(object, key) === this.transactionId;
|
2250
|
+
};
|
2251
|
+
|
2252
|
+
TransactionRunner.prototype.before = function before(context$$1) {
|
2253
|
+
this.inTransaction = true;
|
2254
|
+
this.shouldReflush = false;
|
2255
|
+
{
|
2256
|
+
this.debugStack = context$$1.env.debugStack;
|
2257
|
+
}
|
2258
|
+
};
|
2259
|
+
|
2260
|
+
TransactionRunner.prototype.after = function after() {
|
2261
|
+
this.transactionId++;
|
2262
|
+
this.inTransaction = false;
|
2263
|
+
{
|
2264
|
+
this.debugStack = undefined;
|
2265
|
+
}
|
2266
|
+
this.clearObjectMap();
|
2267
|
+
};
|
2268
|
+
|
2269
|
+
TransactionRunner.prototype.createMap = function createMap(object) {
|
2270
|
+
var map = Object.create(null);
|
2271
|
+
this.weakMap.set(object, map);
|
2272
|
+
if (true && !emberUtils.HAS_NATIVE_WEAKMAP) {
|
2273
|
+
// POLYFILL AND DEBUG
|
2274
|
+
// requires tracking objects
|
2275
|
+
this.objs.push(object);
|
2276
|
+
}
|
2277
|
+
return map;
|
2278
|
+
};
|
2279
|
+
|
2280
|
+
TransactionRunner.prototype.getOrCreateMap = function getOrCreateMap(object) {
|
2281
|
+
var map = this.weakMap.get(object);
|
2282
|
+
if (map === undefined) {
|
2283
|
+
map = this.createMap(object);
|
2284
|
+
}
|
2285
|
+
return map;
|
2286
|
+
};
|
2287
|
+
|
2288
|
+
TransactionRunner.prototype.setKey = function setKey(object, key, value) {
|
2289
|
+
var map = this.getOrCreateMap(object);
|
2290
|
+
map[key] = value;
|
2291
|
+
};
|
2292
|
+
|
2293
|
+
TransactionRunner.prototype.getKey = function getKey(object, key) {
|
2294
|
+
var map = this.weakMap.get(object);
|
2295
|
+
if (map !== undefined) {
|
2296
|
+
return map[key];
|
2297
|
+
}
|
2298
|
+
};
|
2299
|
+
|
2300
|
+
TransactionRunner.prototype.clearObjectMap = function clearObjectMap() {
|
2301
|
+
if (emberUtils.HAS_NATIVE_WEAKMAP) {
|
2302
|
+
// NATIVE AND (DEBUG OR RELEASE)
|
2303
|
+
// if we have a real native weakmap
|
2304
|
+
// releasing the ref will allow the values to be GCed
|
2305
|
+
this.weakMap = new WeakMap$1();
|
2306
|
+
} else {
|
2307
|
+
// POLYFILL AND DEBUG
|
2308
|
+
// with a polyfill the weakmap keys must be cleared since
|
2309
|
+
// they have the last reference, acceptance tests will leak
|
2310
|
+
// the container if you render a immutable object retained
|
2311
|
+
// in module scope.
|
2312
|
+
var objs = this.objs,
|
2313
|
+
weakMap = this.weakMap;
|
2314
|
+
|
2315
|
+
this.objs = [];
|
2316
|
+
for (var i = 0; i < objs.length; i++) {
|
2317
|
+
weakMap.delete(objs[i]);
|
2067
2318
|
}
|
2068
2319
|
}
|
2320
|
+
// POLYFILL AND RELEASE
|
2321
|
+
// we leak the key map if the object is retained but this is
|
2322
|
+
// a POJO of keys to transaction ids
|
2323
|
+
};
|
2069
2324
|
|
2070
|
-
|
2071
|
-
|
2072
|
-
|
2325
|
+
return TransactionRunner;
|
2326
|
+
}();
|
2327
|
+
|
2328
|
+
var runner = new TransactionRunner();
|
2329
|
+
|
2330
|
+
exports.runInTransaction = runner.runInTransaction.bind(runner);
|
2331
|
+
exports.didRender = runner.didRender.bind(runner);
|
2332
|
+
exports.assertNotRendered = runner.assertNotRendered.bind(runner);
|
2073
2333
|
} else {
|
2074
2334
|
// in production do nothing to detect reflushes
|
2075
2335
|
exports.runInTransaction = function (context$$1, methodName) {
|
@@ -3230,14 +3490,6 @@ enifed('ember-metal', ['exports', 'ember-environment', 'ember-utils', 'ember-deb
|
|
3230
3490
|
// inherited, and we can optimize it much better than JS runtimes.
|
3231
3491
|
this.parent = parentMeta;
|
3232
3492
|
|
3233
|
-
if (ember_features.EMBER_GLIMMER_DETECT_BACKTRACKING_RERENDER || ember_features.EMBER_GLIMMER_ALLOW_BACKTRACKING_RERENDER) {
|
3234
|
-
this._lastRendered = undefined;
|
3235
|
-
{
|
3236
|
-
this._lastRenderedReferenceMap = undefined;
|
3237
|
-
this._lastRenderedTemplateMap = undefined;
|
3238
|
-
}
|
3239
|
-
}
|
3240
|
-
|
3241
3493
|
this._listeners = undefined;
|
3242
3494
|
this._listenersFinalized = false;
|
3243
3495
|
this._suspendedListeners = undefined;
|
@@ -3605,29 +3857,6 @@ enifed('ember-metal', ['exports', 'ember-environment', 'ember-utils', 'ember-deb
|
|
3605
3857
|
return Meta;
|
3606
3858
|
}();
|
3607
3859
|
|
3608
|
-
if (ember_features.EMBER_GLIMMER_DETECT_BACKTRACKING_RERENDER || ember_features.EMBER_GLIMMER_ALLOW_BACKTRACKING_RERENDER) {
|
3609
|
-
Meta.prototype.writableLastRendered = function () {
|
3610
|
-
return this._getOrCreateOwnMap('_lastRendered');
|
3611
|
-
};
|
3612
|
-
Meta.prototype.readableLastRendered = function () {
|
3613
|
-
return this._lastRendered;
|
3614
|
-
};
|
3615
|
-
{
|
3616
|
-
Meta.prototype.writableLastRenderedReferenceMap = function () {
|
3617
|
-
return this._getOrCreateOwnMap('_lastRenderedReferenceMap');
|
3618
|
-
};
|
3619
|
-
Meta.prototype.readableLastRenderedReferenceMap = function () {
|
3620
|
-
return this._lastRenderedReferenceMap;
|
3621
|
-
};
|
3622
|
-
Meta.prototype.writableLastRenderedTemplateMap = function () {
|
3623
|
-
return this._getOrCreateOwnMap('_lastRenderedTemplateMap');
|
3624
|
-
};
|
3625
|
-
Meta.prototype.readableLastRenderedTemplateMap = function () {
|
3626
|
-
return this._lastRenderedTemplateMap;
|
3627
|
-
};
|
3628
|
-
}
|
3629
|
-
}
|
3630
|
-
|
3631
3860
|
for (var name in protoMethods) {
|
3632
3861
|
Meta.prototype[name] = protoMethods[name];
|
3633
3862
|
}
|
@@ -5356,146 +5585,6 @@ enifed('ember-metal', ['exports', 'ember-environment', 'ember-utils', 'ember-deb
|
|
5356
5585
|
}
|
5357
5586
|
}
|
5358
5587
|
|
5359
|
-
/**
|
5360
|
-
@module ember
|
5361
|
-
*/
|
5362
|
-
var id = 0;
|
5363
|
-
|
5364
|
-
// Returns whether Type(value) is Object according to the terminology in the spec
|
5365
|
-
function isObject$1(value) {
|
5366
|
-
return typeof value === 'object' && value !== null || typeof value === 'function';
|
5367
|
-
}
|
5368
|
-
|
5369
|
-
/*
|
5370
|
-
* @class Ember.WeakMap
|
5371
|
-
* @public
|
5372
|
-
* @category ember-metal-weakmap
|
5373
|
-
*
|
5374
|
-
* A partial polyfill for [WeakMap](http://www.ecma-international.org/ecma-262/6.0/#sec-weakmap-objects).
|
5375
|
-
*
|
5376
|
-
* There is a small but important caveat. This implementation assumes that the
|
5377
|
-
* weak map will live longer (in the sense of garbage collection) than all of its
|
5378
|
-
* keys, otherwise it is possible to leak the values stored in the weak map. In
|
5379
|
-
* practice, most use cases satisfy this limitation which is why it is included
|
5380
|
-
* in ember-metal.
|
5381
|
-
*/
|
5382
|
-
var WeakMapPolyfill = function () {
|
5383
|
-
function WeakMapPolyfill(iterable) {
|
5384
|
-
emberBabel.classCallCheck(this, WeakMapPolyfill);
|
5385
|
-
|
5386
|
-
this._id = emberUtils.GUID_KEY + id++;
|
5387
|
-
|
5388
|
-
if (iterable === null || iterable === undefined) {
|
5389
|
-
return;
|
5390
|
-
} else if (Array.isArray(iterable)) {
|
5391
|
-
for (var i = 0; i < iterable.length; i++) {
|
5392
|
-
var _iterable$i = iterable[i],
|
5393
|
-
key = _iterable$i[0],
|
5394
|
-
value = _iterable$i[1];
|
5395
|
-
|
5396
|
-
this.set(key, value);
|
5397
|
-
}
|
5398
|
-
} else {
|
5399
|
-
throw new TypeError('The weak map constructor polyfill only supports an array argument');
|
5400
|
-
}
|
5401
|
-
}
|
5402
|
-
|
5403
|
-
/*
|
5404
|
-
* @method get
|
5405
|
-
* @param key {Object | Function}
|
5406
|
-
* @return {Any} stored value
|
5407
|
-
*/
|
5408
|
-
|
5409
|
-
WeakMapPolyfill.prototype.get = function get(obj) {
|
5410
|
-
if (!isObject$1(obj)) {
|
5411
|
-
return undefined;
|
5412
|
-
}
|
5413
|
-
|
5414
|
-
var meta$$1 = exports.peekMeta(obj);
|
5415
|
-
if (meta$$1 !== undefined) {
|
5416
|
-
var map = meta$$1.readableWeak();
|
5417
|
-
if (map !== undefined) {
|
5418
|
-
var val = map[this._id];
|
5419
|
-
if (val === UNDEFINED) {
|
5420
|
-
return undefined;
|
5421
|
-
}
|
5422
|
-
return val;
|
5423
|
-
}
|
5424
|
-
}
|
5425
|
-
};
|
5426
|
-
|
5427
|
-
/*
|
5428
|
-
* @method set
|
5429
|
-
* @param key {Object | Function}
|
5430
|
-
* @param value {Any}
|
5431
|
-
* @return {WeakMap} the weak map
|
5432
|
-
*/
|
5433
|
-
|
5434
|
-
WeakMapPolyfill.prototype.set = function set(obj, value) {
|
5435
|
-
if (!isObject$1(obj)) {
|
5436
|
-
throw new TypeError('Invalid value used as weak map key');
|
5437
|
-
}
|
5438
|
-
|
5439
|
-
if (value === undefined) {
|
5440
|
-
value = UNDEFINED;
|
5441
|
-
}
|
5442
|
-
|
5443
|
-
meta(obj).writableWeak()[this._id] = value;
|
5444
|
-
|
5445
|
-
return this;
|
5446
|
-
};
|
5447
|
-
|
5448
|
-
/*
|
5449
|
-
* @method has
|
5450
|
-
* @param key {Object | Function}
|
5451
|
-
* @return {boolean} if the key exists
|
5452
|
-
*/
|
5453
|
-
|
5454
|
-
WeakMapPolyfill.prototype.has = function has(obj) {
|
5455
|
-
if (!isObject$1(obj)) {
|
5456
|
-
return false;
|
5457
|
-
}
|
5458
|
-
|
5459
|
-
var meta$$1 = exports.peekMeta(obj);
|
5460
|
-
if (meta$$1 !== undefined) {
|
5461
|
-
var map = meta$$1.readableWeak();
|
5462
|
-
if (map !== undefined) {
|
5463
|
-
return map[this._id] !== undefined;
|
5464
|
-
}
|
5465
|
-
}
|
5466
|
-
|
5467
|
-
return false;
|
5468
|
-
};
|
5469
|
-
|
5470
|
-
/*
|
5471
|
-
* @method delete
|
5472
|
-
* @param key {Object | Function}
|
5473
|
-
* @return {boolean} if the key was deleted
|
5474
|
-
*/
|
5475
|
-
|
5476
|
-
WeakMapPolyfill.prototype.delete = function _delete(obj) {
|
5477
|
-
if (this.has(obj)) {
|
5478
|
-
delete exports.peekMeta(obj).writableWeak()[this._id];
|
5479
|
-
return true;
|
5480
|
-
} else {
|
5481
|
-
return false;
|
5482
|
-
}
|
5483
|
-
};
|
5484
|
-
|
5485
|
-
/*
|
5486
|
-
* @method toString
|
5487
|
-
* @return {String}
|
5488
|
-
*/
|
5489
|
-
|
5490
|
-
WeakMapPolyfill.prototype.toString = function toString$$1() {
|
5491
|
-
return '[object WeakMap]';
|
5492
|
-
};
|
5493
|
-
|
5494
|
-
return WeakMapPolyfill;
|
5495
|
-
}();
|
5496
|
-
|
5497
|
-
var weak_map = emberUtils.HAS_NATIVE_WEAKMAP ? WeakMap : WeakMapPolyfill;
|
5498
|
-
|
5499
5588
|
/**
|
5500
5589
|
@module @ember/utils
|
5501
5590
|
*/
|
@@ -8668,7 +8757,7 @@ enifed('ember-metal', ['exports', 'ember-environment', 'ember-utils', 'ember-deb
|
|
8668
8757
|
exports.getWithDefault = getWithDefault;
|
8669
8758
|
exports.set = set;
|
8670
8759
|
exports.trySet = trySet;
|
8671
|
-
exports.WeakMap =
|
8760
|
+
exports.WeakMap = WeakMap$1;
|
8672
8761
|
exports.WeakMapPolyfill = WeakMapPolyfill;
|
8673
8762
|
exports.addListener = addListener;
|
8674
8763
|
exports.hasListeners = hasListeners;
|