dist/ember.debug.js in ember-source-3.0.0.beta.1 vs dist/ember.debug.js in ember-source-3.0.0.beta.2

- old
+ new

@@ -4,11 +4,11 @@ * @copyright Copyright 2011-2018 Tilde Inc. and contributors * Portions Copyright 2006-2011 Strobe Inc. * Portions Copyright 2008-2011 Apple Inc. All rights reserved. * @license Licensed under MIT license * See https://raw.github.com/emberjs/ember.js/master/LICENSE - * @version 3.0.0-beta.1 + * @version 3.0.0-beta.2 */ /*globals process */ var enifed, requireModule, Ember; @@ -9162,19 +9162,10 @@ this.name = name; this.options = options; this.globalOptions = globalOptions; } - Queue.prototype.push = function push(target, method, args, stack) { - this._queue.push(target, method, args, stack); - return { - queue: this, - target: target, - method: method - }; - }; - Queue.prototype.flush = function flush(sync) { var _options = this.options, before = _options.before, after = _options.after; @@ -9244,20 +9235,14 @@ var target = _ref.target, method = _ref.method; var queue = this._queue; var targetQueueMap = this.targetQueues.get(target); - var index = void 0; if (targetQueueMap !== undefined) { - index = targetQueueMap.get(method); - if (index !== undefined) { - targetQueueMap.delete(method); - } + targetQueueMap.delete(method); } - if (index === undefined) { - index = findItem(target, method, queue); - } + var index = findItem(target, method, queue); if (index > -1) { queue.splice(index, 4); return true; } // if not found in current queue @@ -9269,10 +9254,19 @@ return true; } return false; }; + Queue.prototype.push = function push(target, method, args, stack) { + this._queue.push(target, method, args, stack); + return { + queue: this, + target: target, + method: method + }; + }; + Queue.prototype.pushUnique = function pushUnique(target, method, args, stack) { var localQueueMap = this.targetQueues.get(target); if (localQueueMap === undefined) { localQueueMap = new Map(); this.targetQueues.set(target, localQueueMap); @@ -9343,14 +9337,14 @@ DeferredActionQueues.prototype.schedule = function schedule(queueName, target, method, args, onceFlag, stack) { var queues = this.queues; var queue = queues[queueName]; - if (!queue) { + if (queue === undefined) { noSuchQueue(queueName); } - if (!method) { + if (method === undefined || method === null) { noSuchMethod(queueName); } if (onceFlag) { return queue.pushUnique(target, method, args, stack); } else { @@ -9681,30 +9675,47 @@ }; } return this._setTimeout(fn, executeAt); }; - Backburner.prototype.throttle = function throttle(target, method) /*, ...args, wait, [immediate] */{ + Backburner.prototype.throttle = function throttle(targetOrThisArgOrMethod) { var _this2 = this; - for (var _len4 = arguments.length, args = Array(_len4 > 2 ? _len4 - 2 : 0), _key4 = 2; _key4 < _len4; _key4++) { - args[_key4 - 2] = arguments[_key4]; - } - - var immediate = args.pop(); + var target = void 0; + var method = void 0; + var immediate = void 0; var isImmediate = void 0; var wait = void 0; - if (isCoercableNumber(immediate)) { - wait = immediate; + + for (var _len4 = arguments.length, args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) { + args[_key4 - 1] = arguments[_key4]; + } + + if (args.length === 1) { + method = targetOrThisArgOrMethod; + wait = args.pop(); + target = null; isImmediate = true; } else { - wait = args.pop(); - isImmediate = immediate === true; + target = targetOrThisArgOrMethod; + method = args.shift(); + immediate = args.pop(); + if (isString(method)) { + method = target[method]; + } else if (!isFunction(method)) { + args.unshift(method); + method = target; + target = null; + } + if (isCoercableNumber(immediate)) { + wait = immediate; + isImmediate = true; + } else { + wait = args.pop(); + isImmediate = immediate === true; + } } - if (isString(method)) { - method = target[method]; - } var index = findItem(target, method, this._throttlers); if (index > -1) { this._throttlers[index + 2] = args; return this._throttlers[index + 3]; } // throttled @@ -9726,30 +9737,47 @@ } this._throttlers.push(target, method, args, timer); return timer; }; - Backburner.prototype.debounce = function debounce(target, method) /* , wait, [immediate] */{ + Backburner.prototype.debounce = function debounce(targetOrThisArgOrMethod) { var _this3 = this; - for (var _len5 = arguments.length, args = Array(_len5 > 2 ? _len5 - 2 : 0), _key5 = 2; _key5 < _len5; _key5++) { - args[_key5 - 2] = arguments[_key5]; - } - - var immediate = args.pop(); + var target = void 0; + var method = void 0; + var immediate = void 0; var isImmediate = void 0; var wait = void 0; - if (isCoercableNumber(immediate)) { - wait = immediate; + + for (var _len5 = arguments.length, args = Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) { + args[_key5 - 1] = arguments[_key5]; + } + + if (args.length === 1) { + method = targetOrThisArgOrMethod; + wait = args.pop(); + target = null; isImmediate = false; } else { - wait = args.pop(); - isImmediate = immediate === true; + target = targetOrThisArgOrMethod; + method = args.shift(); + immediate = args.pop(); + if (isString(method)) { + method = target[method]; + } else if (!isFunction(method)) { + args.unshift(method); + method = target; + target = null; + } + if (isCoercableNumber(immediate)) { + wait = immediate; + isImmediate = false; + } else { + wait = args.pop(); + isImmediate = immediate === true; + } } - if (isString(method)) { - method = target[method]; - } wait = parseInt(wait, 10); // Remove debouncee var index = findItem(target, method, this._debouncees); if (index > -1) { var timerId = this._debouncees[index + 3]; @@ -11157,11 +11185,11 @@ bootstrap({ context: context, hasTemplate: _emberGlimmer.hasTemplate, setTemplate: _emberGlimmer.setTemplate }); } }); }); -enifed('ember-application/system/application-instance', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-environment', 'ember-views', 'ember-application/system/engine-instance'], function (exports, _emberUtils, _emberMetal, _emberRuntime, _emberEnvironment, _emberViews, _engineInstance) { +enifed('ember-application/system/application-instance', ['exports', 'ember-utils', 'ember-metal', 'ember-environment', 'ember-views', 'ember-application/system/engine-instance', 'ember-glimmer'], function (exports, _emberUtils, _emberMetal, _emberEnvironment, _emberViews, _engineInstance, _emberGlimmer) { 'use strict'; /** The `ApplicationInstance` encapsulates all of the stateful aspects of a running `Application`. @@ -11318,17 +11346,13 @@ var handleTransitionResolve = function () { if (!bootOptions.options.shouldRender) { // No rendering is needed, and routing has completed, simply return. return _this; } else { - return new _emberRuntime.RSVP.Promise(function (resolve) { - // Resolve once rendering is completed. `router.handleURL` returns the transition (as a thennable) - // which resolves once the transition is completed, but the transition completion only queues up - // a scheduled revalidation (into the `render` queue) in the Renderer. - // - // This uses `run.schedule('afterRender', ....)` to resolve after that rendering has completed. - _emberMetal.run.schedule('afterRender', null, resolve, _this); + // Ensure that the visit promise resolves when all rendering has completed + return (0, _emberGlimmer.renderSettled)().then(function () { + return _this; }); } }; var handleTransitionReject = function (error) { @@ -13127,13 +13151,21 @@ var _console4; return (_console4 = console).info.apply(_console4, arguments); }, debug: function () { - var _console5, _console6; + var _console6; - return console.debug && (_console5 = console).debug.apply(_console5, arguments) || (_console6 = console).info.apply(_console6, arguments); // eslint-disable-line no-console + /* eslint-disable no-console */ + if (console.debug) { + var _console5; + + return (_console5 = console).debug.apply(_console5, arguments); + } + + return (_console6 = console).info.apply(_console6, arguments); + /* eslint-enable no-console */ }, assert: function () { var _console7; return (_console7 = console).assert.apply(_console7, arguments); @@ -18801,10 +18833,16 @@ enumerable: true, get: function () { return _renderer._resetRenderers; } }); + Object.defineProperty(exports, 'renderSettled', { + enumerable: true, + get: function () { + return _renderer.renderSettled; + } + }); Object.defineProperty(exports, 'getTemplate', { enumerable: true, get: function () { return _template_registry.getTemplate; } @@ -19134,15 +19172,16 @@ protocol = nodeURL.parse(url).protocol; } return protocol === null ? ':' : protocol; } }); -enifed('ember-glimmer/renderer', ['exports', 'ember-babel', '@glimmer/reference', 'ember-debug', 'ember-metal', 'ember-views', 'ember-glimmer/component', 'ember-glimmer/component-managers/outlet', 'ember-glimmer/component-managers/root', 'ember-glimmer/utils/references', '@glimmer/runtime'], function (exports, _emberBabel, _reference, _emberDebug, _emberMetal, _emberViews, _component, _outlet, _root2, _references, _runtime) { +enifed('ember-glimmer/renderer', ['exports', 'ember-babel', '@glimmer/reference', 'ember-debug', 'ember-metal', 'ember-views', 'ember-glimmer/component', 'ember-glimmer/component-managers/outlet', 'ember-glimmer/component-managers/root', 'ember-glimmer/utils/references', '@glimmer/runtime', 'rsvp'], function (exports, _emberBabel, _reference, _emberDebug, _emberMetal, _emberViews, _component, _outlet, _root2, _references, _runtime, _rsvp) { 'use strict'; exports.InteractiveRenderer = exports.InertRenderer = exports.Renderer = exports.DynamicScope = undefined; exports._resetRenderers = _resetRenderers; + exports.renderSettled = renderSettled; var backburner = _emberMetal.run.backburner; var DynamicScope = exports.DynamicScope = function () { function DynamicScope(view, outletState, rootOutletState) { (0, _emberBabel.classCallCheck)(this, DynamicScope); @@ -19262,10 +19301,39 @@ for (var i = 0; i < renderers.length; i++) { renderers[i]._scheduleRevalidate(); } } function K() {} + var renderSettledDeferred = null; + /* + Returns a promise which will resolve when rendering has settled. Settled in + this context is defined as when all of the tags in use are "current" (e.g. + `renderers.every(r => r._isValid())`). When this is checked at the _end_ of + the run loop, this essentially guarantees that all rendering is completed. + + @method renderSettled + @returns {Promise<void>} a promise which fulfills when rendering has settled + */ + function renderSettled() { + if (renderSettledDeferred === null) { + renderSettledDeferred = _rsvp.default.defer(); + // if there is no current runloop, the promise created above will not have + // a chance to resolve (because its resolved in backburner's "end" event) + if (!_emberMetal.run.currentRunLoop) { + // ensure a runloop has been kicked off + backburner.schedule('actions', null, K); + } + } + return renderSettledDeferred.promise; + } + function resolveRenderPromise() { + if (renderSettledDeferred !== null) { + var resolve = renderSettledDeferred.resolve; + renderSettledDeferred = null; + backburner.join(null, resolve); + } + } var loops = 0; function loopEnd() { for (var i = 0; i < renderers.length; i++) { if (!renderers[i]._isValid()) { if (loops > 10) { @@ -19277,10 +19345,11 @@ loops++; return backburner.join(null, K); } } loops = 0; + resolveRenderPromise(); } backburner.on('begin', loopBegin); backburner.on('end', loopEnd); var Renderer = exports.Renderer = function () { @@ -21814,16 +21883,15 @@ return OutletView; }(); exports.default = OutletView; }); -enifed('ember-metal', ['exports', 'ember-environment', 'ember-utils', 'ember-debug', 'ember/features', 'ember-babel', '@glimmer/reference', 'require', 'backburner', 'ember-console'], function (exports, emberEnvironment, emberUtils, emberDebug, features, emberBabel, reference, require, Backburner, Logger) { +enifed('ember-metal', ['exports', 'ember-environment', 'ember-utils', 'ember-debug', 'ember/features', 'ember-babel', '@glimmer/reference', 'require', 'backburner'], function (exports, emberEnvironment, emberUtils, emberDebug, features, emberBabel, reference, require, Backburner) { 'use strict'; require = require && require.hasOwnProperty('default') ? require['default'] : require; Backburner = Backburner && Backburner.hasOwnProperty('default') ? Backburner['default'] : Backburner; - Logger = Logger && Logger.hasOwnProperty('default') ? Logger['default'] : Logger; /** @module ember */ @@ -23173,11 +23241,11 @@ } else if (features.DESCRIPTOR_TRAP) { // Future traveler, although this code looks scary. It merely exists in // development to aid in development asertions. Production builds of // ember strip this entire branch out. var messageFor = function (obj, keyName, property, value) { - return 'You attempted to access the `' + keyName + '.' + property + '` property ' + ('(of ' + obj + '). Due to certain internal implementation details of Ember, ') + ('the `' + keyName + '` property previously contained an internal "descriptor" ') + ('object (a private API), therefore `' + keyName + '.' + property + '` would have ') + ('been `' + String(value).replace(/\n/g, ' ') + '`. This internal implementation ') + 'detail was never intended to be a public (or even intimate) API.\n\n' + 'This internal implementation detail has now changed and the (still private) ' + '"descriptor" object has been relocated to the object\'s "meta" (also a ' + ('private API). Soon, accessing `' + keyName + '` on this object will ') + 'return the computed value (see RFC #281 for more details).\n\n' + 'If you are seeing this error, you are likely using an addon that ' + 'relies on this now-defunct private implementation detail. If you can, ' + 'find out which addon is doing this from the stack trace below and ' + 'report this bug to the addon authors. If you feel stuck, the Ember ' + 'Community Slack (https://ember-community-slackin.herokuapp.com/) ' + 'may be able to offer some help.\n\n' + 'If you are an addon author and need help transitioning your code, ' + 'please get in touch in the #dev-ember channel in the Ember Community ' + 'Slack.'; + return 'You attempted to access the `' + keyName + '.' + String(property) + '` property ' + ('(of ' + obj + '). Due to certain internal implementation details of Ember, ') + ('the `' + keyName + '` property previously contained an internal "descriptor" ') + ('object (a private API), therefore `' + keyName + '.' + String(property) + '` would have ') + ('been `' + String(value).replace(/\n/g, ' ') + '`. This internal implementation ') + 'detail was never intended to be a public (or even intimate) API.\n\n' + 'This internal implementation detail has now changed and the (still private) ' + '"descriptor" object has been relocated to the object\'s "meta" (also a ' + ('private API). Soon, accessing `' + keyName + '` on this object will ') + 'return the computed value (see RFC #281 for more details).\n\n' + 'If you are seeing this error, you are likely using an addon that ' + 'relies on this now-defunct private implementation detail. If you can, ' + 'find out which addon is doing this from the stack trace below and ' + 'report this bug to the addon authors. If you feel stuck, the Ember ' + 'Community Slack (https://ember-community-slackin.herokuapp.com/) ' + 'may be able to offer some help.\n\n' + 'If you are an addon author and need help transitioning your code, ' + 'please get in touch in the #dev-ember channel in the Ember Community ' + 'Slack.'; }; var trapFor = void 0; if (emberUtils.HAS_NATIVE_PROXY) { @@ -23185,11 +23253,13 @@ trapFor = function (obj, keyName, descriptor) { return new Proxy(descriptor, { get: function (descriptor, property) { if (property === DESCRIPTOR) { return descriptor; - } else if (property === 'toString' || property == 'valueOf' || Symbol && property === Symbol.toPrimitive) { + } else if (property === 'prototype' || property === 'constructor' || property === 'nodeType') { + return undefined; + } else if (property === 'toString' || property === 'valueOf' || property === 'inspect' || Symbol && property === Symbol.toPrimitive || Symbol && property === Symbol.toStringTag) { return function () { return '[COMPUTED PROPERTY]'; }; } @@ -23937,11 +24007,13 @@ this._descriptors = undefined; } this._watching = undefined; this._mixins = undefined; - this._bindings = undefined; + if (emberEnvironment.ENV._ENABLE_BINDING_SUPPORT) { + this._bindings = undefined; + } this._values = undefined; this._deps = undefined; this._chainWatchers = undefined; this._chains = undefined; this._tag = undefined; @@ -24260,21 +24332,26 @@ pointer = pointer.parent; } }; Meta.prototype.writeBindings = function writeBindings(subkey, value) { + true && !emberEnvironment.ENV._ENABLE_BINDING_SUPPORT && emberDebug.assert('Cannot invoke `meta.writeBindings` when EmberENV._ENABLE_BINDING_SUPPORT is not set', emberEnvironment.ENV._ENABLE_BINDING_SUPPORT); true && !!this.isMetaDestroyed() && emberDebug.assert('Cannot add a binding for `' + subkey + '` on `' + emberUtils.toString(this.source) + '` after it has been destroyed.', !this.isMetaDestroyed()); var map = this._getOrCreateOwnMap('_bindings'); map[subkey] = value; }; Meta.prototype.peekBindings = function peekBindings(subkey) { + true && !emberEnvironment.ENV._ENABLE_BINDING_SUPPORT && emberDebug.assert('Cannot invoke `meta.peekBindings` when EmberENV._ENABLE_BINDING_SUPPORT is not set', emberEnvironment.ENV._ENABLE_BINDING_SUPPORT); + return this._findInherited('_bindings', subkey); }; Meta.prototype.forEachBindings = function forEachBindings(fn) { + true && !emberEnvironment.ENV._ENABLE_BINDING_SUPPORT && emberDebug.assert('Cannot invoke `meta.forEachBindings` when EmberENV._ENABLE_BINDING_SUPPORT is not set', emberEnvironment.ENV._ENABLE_BINDING_SUPPORT); + var pointer = this; var seen = void 0; while (pointer !== undefined) { var map = pointer._bindings; if (map !== undefined) { @@ -24289,10 +24366,11 @@ pointer = pointer.parent; } }; Meta.prototype.clearBindings = function clearBindings() { + true && !emberEnvironment.ENV._ENABLE_BINDING_SUPPORT && emberDebug.assert('Cannot invoke `meta.clearBindings` when EmberENV._ENABLE_BINDING_SUPPORT is not set', emberEnvironment.ENV._ENABLE_BINDING_SUPPORT); true && !!this.isMetaDestroyed() && emberDebug.assert('Cannot clear bindings on `' + emberUtils.toString(this.source) + '` after it has been destroyed.', !this.isMetaDestroyed()); this._bindings = undefined; }; @@ -24646,18 +24724,10 @@ function isPath(path) { return firstDotIndexCache.get(path) !== -1; } - function getFirstKey(path) { - return firstKeyCache.get(path); - } - - function getTailPath(path) { - return tailPathCache.get(path); - } - /** @module @ember/object */ var ALLOWABLE_TYPES = { @@ -27625,493 +27695,10 @@ }); return properties; } /** - @module ember - */ - - // .......................................................... - // BINDING - // - - var Binding = function () { - function Binding(toPath, fromPath) { - emberBabel.classCallCheck(this, Binding); - - // Configuration - this._from = fromPath; - this._to = toPath; - this._oneWay = undefined; - - // State - this._direction = undefined; - this._readyToSync = undefined; - this._fromObj = undefined; - this._fromPath = undefined; - this._toObj = undefined; - } - - /** - @class Binding - @namespace Ember - @deprecated See https://emberjs.com/deprecations/v2.x#toc_ember-binding - @public - */ - - /** - This copies the Binding so it can be connected to another object. - @method copy - @return {Ember.Binding} `this` - @public - */ - - Binding.prototype.copy = function copy() { - var copy = new Binding(this._to, this._from); - if (this._oneWay) { - copy._oneWay = true; - } - return copy; - }; - - // .......................................................... - // CONFIG - // - - /** - This will set `from` property path to the specified value. It will not - attempt to resolve this property path to an actual object until you - connect the binding. - The binding will search for the property path starting at the root object - you pass when you `connect()` the binding. It follows the same rules as - `get()` - see that method for more information. - @method from - @param {String} path The property path to connect to. - @return {Ember.Binding} `this` - @public - */ - - Binding.prototype.from = function from(path) { - this._from = path; - return this; - }; - - /** - This will set the `to` property path to the specified value. It will not - attempt to resolve this property path to an actual object until you - connect the binding. - The binding will search for the property path starting at the root object - you pass when you `connect()` the binding. It follows the same rules as - `get()` - see that method for more information. - @method to - @param {String|Tuple} path A property path or tuple. - @return {Ember.Binding} `this` - @public - */ - - Binding.prototype.to = function to(path) { - this._to = path; - return this; - }; - - /** - Configures the binding as one way. A one-way binding will relay changes - on the `from` side to the `to` side, but not the other way around. This - means that if you change the `to` side directly, the `from` side may have - a different value. - @method oneWay - @return {Ember.Binding} `this` - @public - */ - - Binding.prototype.oneWay = function oneWay() { - this._oneWay = true; - return this; - }; - - /** - @method toString - @return {String} string representation of binding - @public - */ - - Binding.prototype.toString = function toString$$1() { - var oneWay = this._oneWay ? '[oneWay]' : ''; - return 'Ember.Binding<' + emberUtils.guidFor(this) + '>(' + this._from + ' -> ' + this._to + ')' + oneWay; - }; - - // .......................................................... - // CONNECT AND SYNC - // - - /** - Attempts to connect this binding instance so that it can receive and relay - changes. This method will raise an exception if you have not set the - from/to properties yet. - @method connect - @param {Object} obj The root object for this binding. - @return {Ember.Binding} `this` - @public - */ - - Binding.prototype.connect = function connect(obj) { - true && !!!obj && emberDebug.assert('Must pass a valid object to Ember.Binding.connect()', !!obj); - - var fromObj = void 0, - fromPath = void 0, - possibleGlobal = void 0; - - // If the binding's "from" path could be interpreted as a global, verify - // whether the path refers to a global or not by consulting `Ember.lookup`. - if (isGlobalPath(this._from)) { - var name = getFirstKey(this._from); - possibleGlobal = emberEnvironment.context.lookup[name]; - - if (possibleGlobal) { - fromObj = possibleGlobal; - fromPath = getTailPath(this._from); - } - } - - if (fromObj === undefined) { - fromObj = obj; - fromPath = this._from; - } - - trySet(obj, this._to, get(fromObj, fromPath)); - - // Add an observer on the object to be notified when the binding should be updated. - addObserver(fromObj, fromPath, this, 'fromDidChange'); - - // If the binding is a two-way binding, also set up an observer on the target. - if (!this._oneWay) { - addObserver(obj, this._to, this, 'toDidChange'); - } - - addListener(obj, 'willDestroy', this, 'disconnect'); - - fireDeprecations(obj, this._to, this._from, possibleGlobal, this._oneWay, !possibleGlobal && !this._oneWay); - - this._readyToSync = true; - this._fromObj = fromObj; - this._fromPath = fromPath; - this._toObj = obj; - - return this; - }; - - /** - Disconnects the binding instance. Changes will no longer be relayed. You - will not usually need to call this method. - @method disconnect - @return {Ember.Binding} `this` - @public - */ - - Binding.prototype.disconnect = function disconnect() { - true && !!!this._toObj && emberDebug.assert('Must pass a valid object to Ember.Binding.disconnect()', !!this._toObj); - - // Remove an observer on the object so we're no longer notified of - // changes that should update bindings. - - removeObserver(this._fromObj, this._fromPath, this, 'fromDidChange'); - - // If the binding is two-way, remove the observer from the target as well. - if (!this._oneWay) { - removeObserver(this._toObj, this._to, this, 'toDidChange'); - } - - this._readyToSync = false; // Disable scheduled syncs... - return this; - }; - - // .......................................................... - // PRIVATE - // - - /* Called when the from side changes. */ - - Binding.prototype.fromDidChange = function fromDidChange(target) { - // eslint-disable-line no-unused-vars - this._scheduleSync('fwd'); - }; - - /* Called when the to side changes. */ - - Binding.prototype.toDidChange = function toDidChange(target) { - // eslint-disable-line no-unused-vars - this._scheduleSync('back'); - }; - - Binding.prototype._scheduleSync = function _scheduleSync(dir) { - var existingDir = this._direction; - - // If we haven't scheduled the binding yet, schedule it. - if (existingDir === undefined) { - run.schedule('sync', this, '_sync'); - this._direction = dir; - } - - // If both a 'back' and 'fwd' sync have been scheduled on the same object, - // default to a 'fwd' sync so that it remains deterministic. - if (existingDir === 'back' && dir === 'fwd') { - this._direction = 'fwd'; - } - }; - - Binding.prototype._sync = function _sync() { - var log = emberEnvironment.ENV.LOG_BINDINGS; - - var toObj = this._toObj; - - // Don't synchronize destroyed objects or disconnected bindings. - if (toObj.isDestroyed || !this._readyToSync) { - return; - } - - // Get the direction of the binding for the object we are - // synchronizing from. - var direction = this._direction; - - var fromObj = this._fromObj; - var fromPath = this._fromPath; - - this._direction = undefined; - - // If we're synchronizing from the remote object... - if (direction === 'fwd') { - var fromValue = get(fromObj, fromPath); - if (log) { - Logger.log(' ', this.toString(), '->', fromValue, fromObj); - } - if (this._oneWay) { - trySet(toObj, this._to, fromValue); - } else { - _suspendObserver(toObj, this._to, this, 'toDidChange', function () { - trySet(toObj, this._to, fromValue); - }); - } - // If we're synchronizing *to* the remote object. - } else if (direction === 'back') { - var toValue = get(toObj, this._to); - if (log) { - Logger.log(' ', this.toString(), '<-', toValue, toObj); - } - _suspendObserver(fromObj, fromPath, this, 'fromDidChange', function () { - trySet(fromObj, fromPath, toValue); - }); - } - }; - - return Binding; - }(); - - function fireDeprecations(obj, toPath, fromPath, deprecateGlobal, deprecateOneWay, deprecateAlias) { - var deprecateGlobalMessage = '`Ember.Binding` is deprecated. Since you' + ' are binding to a global consider using a service instead.'; - var deprecateOneWayMessage = '`Ember.Binding` is deprecated. Since you' + ' are using a `oneWay` binding consider using a `readOnly` computed' + ' property instead.'; - var deprecateAliasMessage = '`Ember.Binding` is deprecated. Consider' + ' using an `alias` computed property instead.'; - - var objectInfo = 'The `' + toPath + '` property of `' + obj + '` is an `Ember.Binding` connected to `' + fromPath + '`, but '; - true && !!deprecateGlobal && emberDebug.deprecate(objectInfo + deprecateGlobalMessage, !deprecateGlobal, { - id: 'ember-metal.binding', - until: '3.0.0', - url: 'https://emberjs.com/deprecations/v2.x#toc_ember-binding' - }); - true && !!deprecateOneWay && emberDebug.deprecate(objectInfo + deprecateOneWayMessage, !deprecateOneWay, { - id: 'ember-metal.binding', - until: '3.0.0', - url: 'https://emberjs.com/deprecations/v2.x#toc_ember-binding' - }); - true && !!deprecateAlias && emberDebug.deprecate(objectInfo + deprecateAliasMessage, !deprecateAlias, { - id: 'ember-metal.binding', - until: '3.0.0', - url: 'https://emberjs.com/deprecations/v2.x#toc_ember-binding' - }); - } - - function mixinProperties$1(to, from) { - for (var key in from) { - if (from.hasOwnProperty(key)) { - to[key] = from[key]; - } - } - } - - mixinProperties$1(Binding, { - - /* - See `Ember.Binding.from`. - @method from - @static - */ - from: function (from) { - var C = this; - return new C(undefined, from); - }, - - /* - See `Ember.Binding.to`. - @method to - @static - */ - to: function (to) { - var C = this; - return new C(to, undefined); - } - }); - /** - An `Ember.Binding` connects the properties of two objects so that whenever - the value of one property changes, the other property will be changed also. - - ## Automatic Creation of Bindings with `/^*Binding/`-named Properties. - - You do not usually create Binding objects directly but instead describe - bindings in your class or object definition using automatic binding - detection. - - Properties ending in a `Binding` suffix will be converted to `Ember.Binding` - instances. The value of this property should be a string representing a path - to another object or a custom binding instance created using Binding helpers - (see "One Way Bindings"): - - ``` - valueBinding: "MyApp.someController.title" - ``` - - This will create a binding from `MyApp.someController.title` to the `value` - property of your object instance automatically. Now the two values will be - kept in sync. - - ## One Way Bindings - - One especially useful binding customization you can use is the `oneWay()` - helper. This helper tells Ember that you are only interested in - receiving changes on the object you are binding from. For example, if you - are binding to a preference and you want to be notified if the preference - has changed, but your object will not be changing the preference itself, you - could do: - - ``` - bigTitlesBinding: Ember.Binding.oneWay("MyApp.preferencesController.bigTitles") - ``` - - This way if the value of `MyApp.preferencesController.bigTitles` changes the - `bigTitles` property of your object will change also. However, if you - change the value of your `bigTitles` property, it will not update the - `preferencesController`. - - One way bindings are almost twice as fast to setup and twice as fast to - execute because the binding only has to worry about changes to one side. - - You should consider using one way bindings anytime you have an object that - may be created frequently and you do not intend to change a property; only - to monitor it for changes (such as in the example above). - - ## Adding Bindings Manually - - All of the examples above show you how to configure a custom binding, but the - result of these customizations will be a binding template, not a fully active - Binding instance. The binding will actually become active only when you - instantiate the object the binding belongs to. It is useful, however, to - understand what actually happens when the binding is activated. - - For a binding to function it must have at least a `from` property and a `to` - property. The `from` property path points to the object/key that you want to - bind from while the `to` path points to the object/key you want to bind to. - - When you define a custom binding, you are usually describing the property - you want to bind from (such as `MyApp.someController.value` in the examples - above). When your object is created, it will automatically assign the value - you want to bind `to` based on the name of your binding key. In the - examples above, during init, Ember objects will effectively call - something like this on your binding: - - ```javascript - binding = Ember.Binding.from("valueBinding").to("value"); - ``` - - This creates a new binding instance based on the template you provide, and - sets the to path to the `value` property of the new object. Now that the - binding is fully configured with a `from` and a `to`, it simply needs to be - connected to become active. This is done through the `connect()` method: - - ```javascript - binding.connect(this); - ``` - - Note that when you connect a binding you pass the object you want it to be - connected to. This object will be used as the root for both the from and - to side of the binding when inspecting relative paths. This allows the - binding to be automatically inherited by subclassed objects as well. - - This also allows you to bind between objects using the paths you declare in - `from` and `to`: - - ```javascript - // Example 1 - binding = Ember.Binding.from("App.someObject.value").to("value"); - binding.connect(this); - - // Example 2 - binding = Ember.Binding.from("parentView.value").to("App.someObject.value"); - binding.connect(this); - ``` - - Now that the binding is connected, it will observe both the from and to side - and relay changes. - - If you ever needed to do so (you almost never will, but it is useful to - understand this anyway), you could manually create an active binding by - using the `Ember.bind()` helper method. (This is the same method used by - to setup your bindings on objects): - - ```javascript - Ember.bind(MyApp.anotherObject, "value", "MyApp.someController.value"); - ``` - - Both of these code fragments have the same effect as doing the most friendly - form of binding creation like so: - - ```javascript - MyApp.anotherObject = Ember.Object.create({ - valueBinding: "MyApp.someController.value", - - // OTHER CODE FOR THIS OBJECT... - }); - ``` - - Ember's built in binding creation method makes it easy to automatically - create bindings for you. You should always use the highest-level APIs - available, even if you understand how it works underneath. - - @class Binding - @namespace Ember - @since Ember 0.9 - @public - */ - // Ember.Binding = Binding; ES6TODO: where to put this? - - - /** - Global helper method to create a new binding. Just pass the root object - along with a `to` and `from` path to create and connect the binding. - - @method bind - @for Ember - @param {Object} obj The root object of the transform. - @param {String} to The path to the 'to' side of the binding. - Must be relative to obj. - @param {String} from The path to the 'from' side of the binding. - Must be relative to obj or a global path. - @return {Ember.Binding} binding instance - @public - */ - function bind(obj, to, from) { - return new Binding(to, from).connect(obj); - } - - /** @module @ember/object */ var a_concat = Array.prototype.concat; var isArray = Array.isArray; @@ -28341,44 +27928,10 @@ } } } } - function detectBinding(key) { - var length = key.length; - - return length > 7 && key.charCodeAt(length - 7) === 66 && key.indexOf('inding', length - 6) !== -1; - } - // warm both paths of above function - detectBinding('notbound'); - detectBinding('fooBinding'); - - function connectBindings(obj, meta$$1) { - // TODO Mixin.apply(instance) should disconnect binding if exists - meta$$1.forEachBindings(function (key, binding) { - if (binding) { - var to = key.slice(0, -7); // strip Binding off end - if (binding instanceof Binding) { - binding = binding.copy(); // copy prototypes' instance - binding.to(to); - } else { - // binding is string path - binding = new Binding(to, binding); - } - binding.connect(obj); - obj[key] = binding; - } - }); - // mark as applied - meta$$1.clearBindings(); - } - - function finishPartial(obj, meta$$1) { - connectBindings(obj, meta$$1 === undefined ? meta(obj) : meta$$1); - return obj; - } - function followAlias(obj, desc, descs, values) { var altKey = desc.methodName; var value = void 0; var possibleDesc = void 0; if (descs[altKey] || values[altKey]) { @@ -28464,20 +28017,20 @@ replaceObserversAndListeners(obj, key, null, value); } else { replaceObserversAndListeners(obj, key, obj[key], value); } - if (detectBinding(key)) { + if (emberEnvironment.ENV._ENABLE_BINDING_SUPPORT && Mixin.detectBinding(key)) { meta$$1.writeBindings(key, value); } defineProperty(obj, key, desc, value, meta$$1); } - if (!partial) { + if (emberEnvironment.ENV._ENABLE_BINDING_SUPPORT && !partial) { // don't apply to prototype - finishPartial(obj, meta$$1); + Mixin.finishPartial(obj, meta$$1); } return obj; } @@ -28752,11 +28305,16 @@ return Mixin; }(); Mixin._apply = applyMixin; - Mixin.finishPartial = finishPartial; + if (emberEnvironment.ENV._ENABLE_BINDING_SUPPORT) { + // slotting this so that the legacy addon can add the function here + // without triggering an error due to the Object.seal done below + Mixin.finishPartial = null; + Mixin.detectBinding = null; + } var MixinPrototype = Mixin.prototype; MixinPrototype.toString = Object.toString; emberDebug.debugSeal(MixinPrototype); @@ -29175,13 +28733,10 @@ exports.observer = observer; exports.required = required; exports.REQUIRED = REQUIRED; exports.hasUnprocessedMixins = hasUnprocessedMixins; exports.clearUnprocessedMixins = clearUnprocessedMixins; - exports.detectBinding = detectBinding; - exports.Binding = Binding; - exports.bind = bind; exports.isGlobalPath = isGlobalPath; exports.InjectedProperty = InjectedProperty; exports.setHasViews = setHasViews; exports.tagForProperty = tagForProperty; exports.tagFor = tagFor; @@ -33843,10 +33398,14 @@ var diff = a - b; return (diff > 0) - (diff < 0); } /** + @module @ember/utils + */ + + /** Compares two javascript values and returns: - -1 if the first is smaller than the second, - 0 if both are equal, - 1 if the first is greater than the second. @@ -33877,11 +33436,12 @@ Ember.compare('hello', 50); // 1 Ember.compare(50, 'hello'); // -1 ``` @method compare - @for Ember + @for @ember/utils + @static @param {Object} v First value to compare @param {Object} w Second value to compare @return {Number} -1 if v < w, 0 if v = w and 1 if v > w. @public */ @@ -35376,15 +34936,15 @@ Example ```javascript let ToDoList = Ember.Object.extend({ // using standard ascending sort - todosSorting: ['name'], + todosSorting: Object.freeze(['name']), sortedTodos: Ember.computed.sort('todos', 'todosSorting'), // using descending sort - todosSortingDesc: ['name:desc'], + todosSortingDesc: Object.freeze(['name:desc']), sortedTodosDesc: Ember.computed.sort('todos', 'todosSortingDesc'), // using a custom sort function priorityTodos: Ember.computed.sort('todos', function(a, b){ if (a.priority > b.priority) { @@ -36517,10 +36077,13 @@ enifed('ember-runtime/is-equal', ['exports'], function (exports) { 'use strict'; exports.default = isEqual; /** + @module @ember/utils + */ + /** Compares two objects, returning true if they are equal. ```javascript Ember.isEqual('hello', 'hello'); // true Ember.isEqual(1, 2); // false @@ -36548,11 +36111,12 @@ ```javascript Ember.isEqual([4, 2], [4, 2]); // false ``` @method isEqual - @for Ember + @for @ember/utils + @static @param {Object} a first object to compare @param {Object} b second object to compare @return {Boolean} @public */ @@ -39764,11 +39328,10 @@ var _Mixin$create, _ClassMixinProps; var schedule = _emberMetal.run.schedule; var applyMixin = _emberMetal.Mixin._apply; - var finishPartial = _emberMetal.Mixin.finishPartial; var reopen = _emberMetal.Mixin.prototype.reopen; var POST_INIT = exports.POST_INIT = (0, _emberUtils.symbol)('POST_INIT'); function makeCtor() { @@ -39826,11 +39389,11 @@ for (var j = 0; j < keyNames.length; j++) { var keyName = keyNames[j]; var value = properties[keyName]; - if ((0, _emberMetal.detectBinding)(keyName)) { + if (_emberEnvironment.ENV._ENABLE_BINDING_SUPPORT && _emberMetal.Mixin.detectBinding(keyName)) { m.writeBindings(keyName, value); } (true && !(!(value instanceof _emberMetal.ComputedProperty)) && (0, _emberDebug.assert)('Ember.Object.create no longer supports defining computed ' + 'properties. Define computed properties using extend() or reopen() ' + 'before calling create().', !(value instanceof _emberMetal.ComputedProperty))); (true && !(!(typeof value === 'function' && value.toString().indexOf('._super') !== -1)) && (0, _emberDebug.assert)('Ember.Object.create no longer supports defining methods that call _super.', !(typeof value === 'function' && value.toString().indexOf('._super') !== -1))); @@ -39869,11 +39432,13 @@ } } } } - finishPartial(this, m); + if (_emberEnvironment.ENV._ENABLE_BINDING_SUPPORT) { + _emberMetal.Mixin.finishPartial(this, m); + } this.init.apply(this, arguments); this[POST_INIT](); @@ -44588,10 +44153,14 @@ function canInvoke(obj, methodName) { return obj !== null && obj !== undefined && typeof obj[methodName] === 'function'; } /** + @module @ember/utils + */ + + /** Checks to see if the `methodName` exists on the `obj`, and if it does, invokes it with the arguments passed. ```javascript let d = new Date('03/15/2013'); @@ -44600,11 +44169,12 @@ Ember.tryInvoke(d, 'setFullYear', [2014]); // 1394856000000 Ember.tryInvoke(d, 'noSuchMethod', [2014]); // undefined ``` @method tryInvoke - @for Ember + @for @ember/utils + @static @param {Object} obj The object to check for the method @param {String} methodName The method name to check for @param {Array} [args] The arguments to pass to the method @return {*} the return value of the invoked method or undefined if it cannot be invoked @public @@ -47221,10 +46791,10 @@ */ }); enifed("ember/version", ["exports"], function (exports) { "use strict"; - exports.default = "3.0.0-beta.1"; + exports.default = "3.0.0-beta.2"; }); enifed("handlebars", ["exports"], function (exports) { "use strict"; // File ignored in coverage tests via setting in .istanbul.yml