language
stringclasses
1 value
owner
stringlengths
2
15
repo
stringlengths
2
21
sha
stringlengths
45
45
message
stringlengths
7
36.3k
path
stringlengths
1
199
patch
stringlengths
15
102k
is_multipart
bool
2 classes
Other
emberjs
ember.js
b5a5c115a83db849eb1a6bb4f022e45767ed4ab5.json
Fix Handlebars in builds
Assetfile
@@ -85,7 +85,7 @@ end distros = { :runtime => %w(ember-metal ember-runtime), - :full => %w(handlebars ember-metal ember-runtime ember-application ember-views ember-states ember-routing ember-viewstates metamorph ember-handlebars) + :full => %w(ember-metal ember-runtime ember-application ember-views ember-states ember-routing ember-viewstates metamorph ember-handlebars) } output "dist"
true
Other
emberjs
ember.js
b5a5c115a83db849eb1a6bb4f022e45767ed4ab5.json
Fix Handlebars in builds
Rakefile
@@ -67,12 +67,12 @@ end desc "Clean build artifacts from previous builds" task :clean do puts "Cleaning build..." - pipeline.clean + rm_rf "dist" # Make sure even things RakeP doesn't know about are cleaned puts "Done" end desc "Upload latest Ember.js build to GitHub repository" -task :upload_latest => :dist do +task :upload_latest => [:clean, :dist] do uploader = setup_uploader # Upload minified first, so non-minified shows up on top
true
Other
emberjs
ember.js
8fd57b354c0e46f2f732a1ff1d75a078200a6fb1.json
Support basic States inside of Routes
packages/ember-routing/lib/routable.js
@@ -78,7 +78,7 @@ Ember.Routable = Ember.Mixin.create({ In general, this will update the browser's URL. */ updateRoute: function(manager, location) { - if (get(this, 'isLeaf')) { + if (get(this, 'isLeafRoute')) { var path = this.absoluteRoute(manager); location.setURL(path); } @@ -130,6 +130,16 @@ Ember.Routable = Ember.Mixin.create({ return typeof get(this, 'route') === 'string'; }).cacheable(), + /** + @private + + Determine if this is the last routeable state + */ + isLeafRoute: Ember.computed(function() { + if (get(this, 'isLeaf')) { return true; } + return !get(this, 'childStates').findProperty('isRoutable'); + }).cacheable(), + /** @private @@ -272,10 +282,12 @@ Ember.Routable = Ember.Mixin.create({ on the state whose path is `/posts` with the path `/2/comments`. */ routePath: function(manager, path) { - if (get(this, 'isLeaf')) { return; } + if (get(this, 'isLeafRoute')) { return; } var childStates = get(this, 'childStates'), match; + childStates = Ember.A(childStates.filterProperty('isRoutable')); + childStates = childStates.sort(function(a, b) { var aDynamicSegments = getPath(a, 'routeMatcher.identifiers.length'), bDynamicSegments = getPath(b, 'routeMatcher.identifiers.length'),
true
Other
emberjs
ember.js
8fd57b354c0e46f2f732a1ff1d75a078200a6fb1.json
Support basic States inside of Routes
packages/ember-routing/lib/router.js
@@ -389,21 +389,34 @@ Ember.Router = Ember.StateManager.extend( route: function(path) { set(this, 'isRouting', true); + var routableState; + try { path = path.replace(/^(?=[^\/])/, "/"); this.send('navigateAway'); this.send('unroutePath', path); - var currentURL = get(this, 'currentState').absoluteRoute(this); + routableState = get(this, 'currentState'); + while (routableState && !routableState.get('isRoutable')) { + routableState = get(routableState, 'parentState'); + } + var currentURL = routableState ? routableState.absoluteRoute(this) : ''; var rest = path.substr(currentURL.length); this.send('routePath', rest); } finally { set(this, 'isRouting', false); } - get(this, 'currentState').updateRoute(this, get(this, 'location')); + routableState = get(this, 'currentState'); + while (routableState && !routableState.get('isRoutable')) { + routableState = get(routableState, 'parentState'); + } + + if (routableState) { + routableState.updateRoute(this, get(this, 'location')); + } }, urlFor: function(path, hash) {
true
Other
emberjs
ember.js
8fd57b354c0e46f2f732a1ff1d75a078200a6fb1.json
Support basic States inside of Routes
packages/ember-routing/tests/routable_test.js
@@ -142,6 +142,46 @@ test("when you descend into a state, the route is set", function() { router.send('ready'); }); +test("when you descend into a state, the route is set even when child states (not routes) are present", function() { + var state = Ember.Route.create({ + ready: function(manager) { + manager.transitionTo('fooChild.barChild.bazChild'); + }, + + fooChild: Ember.Route.create({ + route: 'foo', + + barChild: Ember.Route.create({ + route: 'bar', + + bazChild: Ember.Route.create({ + route: 'baz', + + basicState: Ember.State.create() + }) + }) + }) + }); + + var count = 0; + + var router = Ember.Router.create({ + root: state, + location: { + setURL: function(url) { + if (count === 0) { + equal(url, '/foo/bar/baz', "The current URL should be passed in"); + count++; + } else { + ok(false, "Should not get here"); + } + } + } + }); + + router.send('ready'); +}); + var router; var Post = { find: function(id) {
true
Other
emberjs
ember.js
8fd57b354c0e46f2f732a1ff1d75a078200a6fb1.json
Support basic States inside of Routes
packages/ember-routing/tests/router_test.js
@@ -334,7 +334,32 @@ test("should update route for redirections", function() { }) }); - router.route('/'); + Ember.run(function() { + router.route('/'); + }); equal(location.url, '/login'); }); + +test("respects initialState if leafRoute with child states", function() { + var router = Ember.Router.create({ + location: location, + namespace: namespace, + root: Ember.Route.create({ + foo: Ember.Route.create({ + route: '/foo', + + initialState: 'bar', + + bar: Ember.State.create() + }) + }) + }); + + Ember.run(function() { + router.route('/foo'); + }); + + equal(location.url, '/foo'); + equal(router.getPath('currentState.name'), 'bar'); +});
true
Other
emberjs
ember.js
00c92ef2852abcc037091d5b03701586df121b59.json
Fix typos in docs.
packages/ember-routing/lib/router.js
@@ -154,12 +154,12 @@ var get = Ember.get, getPath = Ember.getPath, set = Ember.set; } Within `deserialize` you should use this information to retrieve or create an appropriate context - object for the given url (e.g. by loading from a remote API or accessing the browser's - `localStorage`). This object must be the `return` value for `deserialize` and will be + object for the given URL (e.g. by loading from a remote API or accessing the browser's + `localStorage`). This object must be the `return` value of `deserialize` and will be passed to the Route's `connectOutlets` and `serialize` methods. When an application's state is changed from within the application itself, the context provided for - the transiton will be passed and `deserialize` is not called (see 'Transitions Between States'). + the transition will be passed and `deserialize` is not called (see 'Transitions Between States'). ### Serializing An Object For URLs with Dynamic Segments When transitioning into a Route whose `route` property contains dynamic segments the Route's @@ -218,7 +218,7 @@ var get = Ember.get, getPath = Ember.getPath, set = Ember.set; App.get('router').send('moveElsewhere'); Will transition the application's state to 'root.bRoute' and trigger an update of the URL to - '#/someOtherLocation + '#/someOtherLocation'. For URL patterns with dynamic segments a context can be supplied as the second argument to `send`. The router will match dynamic segments names to keys on this object and fill in the URL with the @@ -256,7 +256,7 @@ var get = Ember.get, getPath = Ember.getPath, set = Ember.set; During application initialization Ember will detect properties of the application ending in 'Controller', create singleton instances of each class, and assign them as a properties on the router. The property name will be the UpperCamel name converted to lowerCamel format. These controller classes should be subclasses - of Ember.ObjectController, Ember.ArrayController, or a custom Ember.Object that includes the + of Ember.ObjectController, Ember.ArrayController, Ember.Controller, or a custom Ember.Object that includes the Ember.ControllerMixin mixin. App = Ember.Application.create({
false
Other
emberjs
ember.js
857a614babd82f3cbf03fefc0b336a44918f5b0e.json
Make Map copyable
packages/ember-metal/lib/map.js
@@ -20,11 +20,32 @@ require('ember-metal/array'); require('ember-metal/utils'); +require('ember-metal/core'); /** @private */ var guidFor = Ember.guidFor, indexOf = Ember.ArrayPolyfills.indexOf; +var copy = function(obj) { + var output = {}; + + for (var prop in obj) { + if (obj.hasOwnProperty(prop)) { output[prop] = obj[prop]; } + } + + return output; +}; + +var copyMap = function(original, newObject) { + var keys = original.keys.copy(), + values = copy(original.values); + + newObject.keys = keys; + newObject.values = values; + + return newObject; +}; + // This class is used internally by Ember.js and Ember Data. // Please do not use it at this time. We plan to clean it up // and add many tests soon. @@ -81,6 +102,15 @@ OrderedSet.prototype = { toArray: function() { return this.list.slice(); + }, + + copy: function() { + var set = new OrderedSet(); + + set.presenceSet = copy(this.presenceSet); + set.list = this.list.slice(); + + return set; } }; @@ -196,6 +226,10 @@ Map.prototype = { var guid = guidFor(key); callback.call(self, key, values[guid]); }); + }, + + copy: function() { + return copyMap(this, new Map()); } }; @@ -225,3 +259,9 @@ MapWithDefault.prototype.get = function(key) { return defaultValue; } }; + +MapWithDefault.prototype.copy = function() { + return copyMap(this, new MapWithDefault({ + defaultValue: this.defaultValue + })); +};
true
Other
emberjs
ember.js
857a614babd82f3cbf03fefc0b336a44918f5b0e.json
Make Map copyable
packages/ember-metal/tests/map_test.js
@@ -13,22 +13,26 @@ function testMap(variety) { } }); - var mapHasLength = function(expected) { + var mapHasLength = function(expected, theMap) { + theMap = theMap || map; + var length = 0; - map.forEach(function() { + theMap.forEach(function() { length++; }); equal(length, expected, "map should contain " + expected + " items"); }; - var mapHasEntries = function(entries) { + var mapHasEntries = function(entries, theMap) { + theMap = theMap || map; + for (var i = 0, l = entries.length; i < l; i++) { - equal(map.get(entries[i][0]), entries[i][1]); - equal(map.has(entries[i][0]), true); + equal(theMap.get(entries[i][0]), entries[i][1]); + equal(theMap.has(entries[i][0]), true); } - mapHasLength(entries.length); + mapHasLength(entries.length, theMap); }; test("add", function() { @@ -70,6 +74,50 @@ function testMap(variety) { mapHasEntries([]); }); + + test("copy and then update", function() { + map.set(object, "winning"); + map.set(number, "winning"); + map.set(string, "winning"); + + var map2 = map.copy(); + + map2.set(object, "losing"); + map2.set(number, "losing"); + map2.set(string, "losing"); + + mapHasEntries([ + [ object, "winning" ], + [ number, "winning" ], + [ string, "winning" ] + ]); + + mapHasEntries([ + [ object, "losing" ], + [ number, "losing" ], + [ string, "losing" ] + ], map2); + }); + + test("copy and then remove", function() { + map.set(object, "winning"); + map.set(number, "winning"); + map.set(string, "winning"); + + var map2 = map.copy(); + + map2.remove(object); + map2.remove(number); + map2.remove(string); + + mapHasEntries([ + [ object, "winning" ], + [ number, "winning" ], + [ string, "winning" ] + ]); + + mapHasEntries([ ], map2); + }); } for (var i = 0; i < varieties.length; i++) { @@ -90,3 +138,32 @@ test("Retrieving a value that has not been set returns and sets a default value" strictEqual(value, map.get('ohai')); }); + +test("Copying a MapWithDefault copies the default value", function() { + var map = Ember.MapWithDefault.create({ + defaultValue: function(key) { + return [key]; + } + }); + + map.set('ohai', 1); + map.get('bai'); + + var map2 = map.copy(); + + equal(map2.get('ohai'), 1); + deepEqual(map2.get('bai'), ['bai']); + + map2.set('kthx', 3); + + deepEqual(map.get('kthx'), ['kthx']); + equal(map2.get('kthx'), 3); + + deepEqual(map2.get('default'), ['default']); + + map2.defaultValue = function(key) { + return ['tom is on', key]; + }; + + deepEqual(map2.get('drugs'), ['tom is on', 'drugs']); +});
true
Other
emberjs
ember.js
2bce92383aecf5405119e1377c02b36c14268292.json
use method name instead of method
packages/ember-metal/lib/mixin.js
@@ -194,7 +194,7 @@ function applyBeforeObservers(obj, m) { method = beforeObservers[methodName]; paths = method.__ember_observesBefore__; for (i=0, l=paths.length; i<l; i++) { - addBeforeObserver(obj, paths[i], obj, method); + addBeforeObserver(obj, paths[i], null, methodName); } } @@ -211,12 +211,12 @@ function applyObservers(obj, m) { method = observers[methodName]; paths = method.__ember_observes__; for (i=0, l=paths.length; i<l; i++) { - addObserver(obj, paths[i], obj, method); + addObserver(obj, paths[i], null, methodName); } } // mark as applied for future Mixin.apply() - m.beforeObservers = {}; + m.observers = {}; } function finishPartial(obj, m) {
true
Other
emberjs
ember.js
2bce92383aecf5405119e1377c02b36c14268292.json
use method name instead of method
packages/ember-metal/tests/observer_test.js
@@ -333,7 +333,7 @@ testBoth('local observers can be removed', function(get, set) { set(obj, 'bar', 'HI!'); equal(barObserved, 2, 'precond - observers should be fired'); - Ember.removeObserver(obj, 'bar', obj, obj.foo1); + Ember.removeObserver(obj, 'bar', null, 'foo1'); barObserved = 0; set(obj, 'bar', 'HI AGAIN!');
true
Other
emberjs
ember.js
3c348928abc44e91ca1c6f51b539b337fbcb1265.json
Fix failing tests
packages/ember-routing/lib/routable.js
@@ -59,7 +59,7 @@ Ember.Routable = Ember.Mixin.create({ */ stashContext: function(manager, context) { var serialized = this.serialize(manager, context); - Ember.assert('serialize must return a hash', typeof serialized === 'object'); + Ember.assert('serialize must return a hash', !serialized || typeof serialized === 'object'); manager.setStateMeta(this, 'serialized', serialized);
false
Other
emberjs
ember.js
bf5f24cc9ab8c5e6817e970114124e7a78467fd1.json
add hook for desc for willWatch and didUnwatch
packages/ember-metal/lib/watching.js
@@ -430,6 +430,9 @@ Ember.watch = function(obj, keyName) { if (!watching[keyName]) { watching[keyName] = 1; if (isKeyName(keyName)) { + desc = m.descs[keyName]; + if (desc && desc.willWatch) { desc.willWatch(obj, keyName); } + if ('function' === typeof obj.willWatchProperty) { obj.willWatchProperty(keyName); } @@ -454,12 +457,15 @@ Ember.unwatch = function(obj, keyName) { // can't watch length on Array - it is special... if (keyName === 'length' && Ember.typeOf(obj) === 'array') { return this; } - var watching = metaFor(obj).watching; + var m = metaFor(obj), watching = m.watching, desc; if (watching[keyName] === 1) { watching[keyName] = 0; if (isKeyName(keyName)) { + desc = m.descs[keyName]; + if (desc && desc.didUnwatch) { desc.didUnwatch(obj, keyName); } + if ('function' === typeof obj.didUnwatchProperty) { obj.didUnwatchProperty(keyName); }
false
Other
emberjs
ember.js
84e9626522a686c29e6d6f2127d35c2dc9698d80.json
remove unused lastSetValues from meta
packages/ember-metal/lib/utils.js
@@ -173,7 +173,6 @@ Ember.meta = function meta(obj, writable) { descs: {}, watching: {}, values: {}, - lastSetValues: {}, cache: {}, source: obj }); @@ -186,7 +185,6 @@ Ember.meta = function meta(obj, writable) { ret.descs = o_create(ret.descs); ret.values = o_create(ret.values); ret.watching = o_create(ret.watching); - ret.lastSetValues = {}; ret.cache = {}; ret.source = obj;
false
Other
emberjs
ember.js
5f9bbadd713cbaca569fac413c45caa40399c836.json
Add hooks for tests to override core behavior We are experimenting with an approach for the ember-data tests that overrides the entry points into the framework with synchronous versions. These hooks make those experiments possible. Please do not use these hooks in app code :)
packages/ember-metal/lib/accessors.js
@@ -131,6 +131,12 @@ Ember.get = get; */ Ember.set = set; +if (Ember.config.overrideAccessors) { + Ember.config.overrideAccessors(); + get = Ember.get; + set = Ember.set; +} + // .......................................................... // PATHS //
true
Other
emberjs
ember.js
5f9bbadd713cbaca569fac413c45caa40399c836.json
Add hooks for tests to override core behavior We are experimenting with an approach for the ember-data tests that overrides the entry points into the framework with synchronous versions. These hooks make those experiments possible. Please do not use these hooks in app code :)
packages/ember-metal/lib/core.js
@@ -6,10 +6,15 @@ /*globals Em:true ENV */ if ('undefined' === typeof Ember) { + // Create core object. Make it act like an instance of Ember.Namespace so that + // objects assigned to it are given a sane string representation. + Ember = {}; +} + /** @namespace @name Ember - @version 0.9.8.1 + @version 1.0.pre All Ember methods and functions are defined inside of this namespace. You generally should not add new properties to this namespace as it may be @@ -27,17 +32,11 @@ if ('undefined' === typeof Ember) { performance optimizations. */ -// Create core object. Make it act like an instance of Ember.Namespace so that -// objects assigned to it are given a sane string representation. -Ember = {}; - // aliases needed to keep minifiers from removing the global context if ('undefined' !== typeof window) { window.Em = window.Ember = Em = Ember; } -} - // Make sure these are set whether Ember was already defined or not Ember.isNamespace = true; @@ -48,10 +47,10 @@ Ember.toString = function() { return "Ember"; }; /** @static @type String - @default '0.9.8.1' + @default '1.0.pre' @constant */ -Ember.VERSION = '0.9.8.1'; +Ember.VERSION = '1.0.pre'; /** @static @@ -64,6 +63,7 @@ Ember.VERSION = '0.9.8.1'; */ Ember.ENV = 'undefined' === typeof ENV ? {} : ENV; +Ember.config = Ember.config || {}; // .......................................................... // BOOTSTRAP
true
Other
emberjs
ember.js
5f9bbadd713cbaca569fac413c45caa40399c836.json
Add hooks for tests to override core behavior We are experimenting with an approach for the ember-data tests that overrides the entry points into the framework with synchronous versions. These hooks make those experiments possible. Please do not use these hooks in app code :)
packages/ember-runtime/lib/system/core_object.js
@@ -151,6 +151,10 @@ CoreObject.PrototypeMixin = Ember.Mixin.create( } }); +if (Ember.config.overridePrototypeMixin) { + Ember.config.overridePrototypeMixin(CoreObject.PrototypeMixin); +} + CoreObject.__super__ = null; var ClassMixin = Ember.Mixin.create( @@ -268,6 +272,10 @@ var ClassMixin = Ember.Mixin.create( }); +if (Ember.config.overrideClassMixin) { + Ember.config.overrideClassMixin(ClassMixin); +} + CoreObject.ClassMixin = ClassMixin; ClassMixin.apply(CoreObject);
true
Other
emberjs
ember.js
b296e2e276df7531165fd8bea5b2313000a824f4.json
serialize route states recursively
packages/ember-routing/lib/router.js
@@ -92,11 +92,23 @@ Ember.Router = Ember.StateManager.extend( var targetState = this.findStateByPath(currentState, targetStateName); Ember.assert("Your target state name " + targetStateName + " for event " + eventName + " did not resolve to a state", !!targetState); - var hash = targetState.serialize(this, context); + + var hash = this.serializeRecursively(targetState, context); return this.urlFor(targetStateName, hash); }, + /** @private */ + serializeRecursively: function(state, hash) { + hash = state.serialize(this, hash); + var parentState = state.get("parentState"); + if (parentState && parentState instanceof Ember.Route) { + return this.serializeRecursively(parentState, hash); + } else { + return hash; + } + }, + /** @private */ init: function() { this._super();
false
Other
emberjs
ember.js
083d80ba00c0012a3d36e932c2ccca1f24bdbfeb.json
Update documentation of ObjectProxy
packages/ember-runtime/lib/system/object_proxy.js
@@ -80,8 +80,8 @@ delegateDesc = Ember.computed(delegate).volatile(); /** @class - `Ember.ObjectProxy` forwards all properties to a proxied `content` - object. + `Ember.ObjectProxy` forwards all properties not defined by the proxy itself + to a proxied `content` object. object = Ember.Object.create({ name: 'Foo' @@ -99,13 +99,37 @@ delegateDesc = Ember.computed(delegate).volatile(); proxy.set('description', 'Foo is a whizboo baz'); object.get('description') // => 'Foo is a whizboo baz' - While `content` is unset, new properties will be silently discarded. + While `content` is unset, setting a property to be delegated will throw an Error. proxy = Ember.ObjectProxy.create({ - content: null + content: null, + flag: null }); - proxy.set('blackHole', 'data'); - proxy.get('blackHole') // => undefined + proxy.set('flag', true); + proxy.get('flag'); // => true + proxy.get('foo'); // => undefined + proxy.set('foo', 'data'); // throws Error + + Delegated properties can be bound to and will change when content is updated. + + Computed properties on the proxy itself can depend on delegated properties. + + ProxyWithComputedProperty = Ember.ObjectProxy.extend({ + fullName: function () { + var firstName = this.get('firstName'), + lastName = this.get('lastName'); + if (firstName && lastName) { + return firstName + ' ' + lastName; + } + return firstName || lastName; + }.property('firstName', 'lastName') + }); + proxy = ProxyWithComputedProperty.create(); + proxy.get('fullName'); => undefined + proxy.set('content', { + firstName: 'Tom', lastName: 'Dale' + }); // triggers property change for fullName on proxy + proxy.get('fullName'); => 'Tom Dale' */ Ember.ObjectProxy = Ember.Object.extend( /** @scope Ember.ObjectProxy.prototype */ {
false
Other
emberjs
ember.js
d23ea3ab501fc0e8f591a793b927f572436647a1.json
Change app.stateManager to app.router
packages/ember-application/lib/system/application.js
@@ -112,7 +112,7 @@ Ember.Application = Ember.Namespace.extend( } if (router) { - set(this, 'stateManager', router); + set(this, 'router', router); } // By default, the router's namespace is the current application.
true
Other
emberjs
ember.js
d23ea3ab501fc0e8f591a793b927f572436647a1.json
Change app.stateManager to app.router
packages/ember-application/tests/system/application_test.js
@@ -142,21 +142,7 @@ test('initialized application go to initial route', function() { }); app.initialize(app.stateManager); - equal(app.getPath('stateManager.currentState.path'), 'root.index', "The router moved the state into the right place"); -}); - -test("initialize application with non routable stateManager", function() { - Ember.run(function() { - app = Ember.Application.create({ - rootElement: '#qunit-fixture' - }); - - app.stateManager = Ember.StateManager.create({ - start: Ember.State.extend() - }); - }); - - equal(app.getPath('stateManager.currentState.path'), 'start', "Application sucessfuly started"); + equal(app.getPath('router.currentState.path'), 'root.index', "The router moved the state into the right place"); }); test("initialize application with stateManager via initialize call", function() { @@ -178,9 +164,9 @@ test("initialize application with stateManager via initialize call", function() app.initialize(app.Router.create()); }); - equal(app.getPath('stateManager') instanceof Ember.Router, true, "Router was set from initialize call"); - equal(app.getPath('stateManager.location') instanceof Ember.NoneLocation, true, "Location was set from location implementation name"); - equal(app.getPath('stateManager.currentState.path'), 'root.index', "The router moved the state into the right place"); + equal(app.getPath('router') instanceof Ember.Router, true, "Router was set from initialize call"); + equal(app.getPath('router.location') instanceof Ember.NoneLocation, true, "Location was set from location implementation name"); + equal(app.getPath('router.currentState.path'), 'root.index', "The router moved the state into the right place"); }); test("initialize application with stateManager via initialize call from Router class", function() { @@ -202,8 +188,8 @@ test("initialize application with stateManager via initialize call from Router c app.initialize(); }); - equal(app.getPath('stateManager') instanceof Ember.Router, true, "Router was set from initialize call"); - equal(app.getPath('stateManager.currentState.path'), 'root.index', "The router moved the state into the right place"); + equal(app.getPath('router') instanceof Ember.Router, true, "Router was set from initialize call"); + equal(app.getPath('router.currentState.path'), 'root.index', "The router moved the state into the right place"); }); test("injections can be registered in a specified order", function() { @@ -295,7 +281,7 @@ test("ControllerObject class can be initialized with target, controllers and vie stateManager.get('postController').set('view', Ember.View.create()); }); - equal(app.getPath('stateManager.postController.target') instanceof Ember.StateManager, true, "controller has target"); - equal(app.getPath('stateManager.postController.controllers') instanceof Ember.StateManager, true, "controller has controllers"); - equal(app.getPath('stateManager.postController.view') instanceof Ember.View, true, "controller has view"); + equal(app.getPath('router.postController.target') instanceof Ember.StateManager, true, "controller has target"); + equal(app.getPath('router.postController.controllers') instanceof Ember.StateManager, true, "controller has controllers"); + equal(app.getPath('router.postController.view') instanceof Ember.View, true, "controller has view"); });
true
Other
emberjs
ember.js
946cefdc2ec93a36205fa8f32a1e1644bd61451f.json
Avoid deprecation warning for ViewState tests
packages/ember-viewstates/tests/view_state_test.js
@@ -1,6 +1,14 @@ var get = Ember.get, set = Ember.set, getPath = Ember.getPath, setPath = Ember.setPath; -module("Ember.ViewState"); +module("Ember.ViewState", { + setup: function() { + Ember.TESTING_DEPRECATION = true; + }, + + teardown: function() { + Ember.TESTING_DEPRECATION = false; + } +}); test("it inherits from Ember.State", function() { ok(Ember.State.detect(Ember.ViewState), "Ember.ViewState is an Ember.State"); @@ -192,18 +200,18 @@ test("it appends and removes a view to the view specified in the state manager's test("it reports the view associated with the current view state, if any", function() { var view = Ember.View.create(); - + var stateManager = Ember.StateManager.create({ foo: Ember.ViewState.create({ view: view, bar: Ember.State.create() }) }); - + Ember.run(function(){ stateManager.transitionTo('foo.bar'); }); - + equal(get(stateManager, 'currentView'), view, "returns nearest parent view state's view"); });
false
Other
emberjs
ember.js
ac64f2320445f75710a81c3616a0d6bdf1b034d5.json
unify xform observer edition
packages/ember-metal/lib/observer.js
@@ -44,7 +44,7 @@ var DeferredEventQueue = function() { this.queue = []; }; -DeferredEventQueue.prototype.push = function(target, eventName) { +DeferredEventQueue.prototype.push = function(target, eventName, keyName) { var targetSet = this.targetSet, queue = this.queue, targetGuid = Ember.guidFor(target), @@ -56,9 +56,9 @@ DeferredEventQueue.prototype.push = function(target, eventName) { } index = eventNameSet[eventName]; if (index === undefined) { - eventNameSet[eventName] = queue.push(Ember.deferEvent(target, eventName)) - 1; + eventNameSet[eventName] = queue.push(Ember.deferEvent(target, eventName, target, keyName)) - 1; } else { - queue[index] = Ember.deferEvent(target, eventName); + queue[index] = Ember.deferEvent(target, eventName, target, keyName); } }; @@ -74,11 +74,11 @@ DeferredEventQueue.prototype.flush = function() { var queue = new DeferredEventQueue(), beforeObserverSet = new ObserverSet(); /** @private */ -function notifyObservers(obj, eventName, forceNotification) { +function notifyObservers(obj, eventName, keyName, forceNotification) { if (deferred && !forceNotification) { - queue.push(obj, eventName); + queue.push(obj, eventName, keyName); } else { - Ember.sendEvent(obj, eventName); + Ember.sendEvent(obj, eventName, obj, keyName); } } @@ -143,29 +143,13 @@ function beforeEvent(keyName) { } /** @private */ -function changeKey(eventName) { - return eventName.slice(0, -7); -} - -/** @private */ -function beforeKey(eventName) { - return eventName.slice(0, -7); -} - -/** @private */ -function xformChange(target, method, params) { - var obj = params[0], keyName = changeKey(params[1]); - method.call(target, obj, keyName); -} - -/** @private */ -function xformBefore(target, method, params) { - var obj = params[0], keyName = beforeKey(params[1]); - method.call(target, obj, keyName); +function xform(target, method, params) { + var args = [].slice.call(params, 2); + method.apply(target, args); } Ember.addObserver = function(obj, path, target, method) { - Ember.addListener(obj, changeEvent(path), target, method, xformChange); + Ember.addListener(obj, changeEvent(path), target, method, xform); Ember.watch(obj, path); return this; }; @@ -182,7 +166,7 @@ Ember.removeObserver = function(obj, path, target, method) { }; Ember.addBeforeObserver = function(obj, path, target, method) { - Ember.addListener(obj, beforeEvent(path), target, method, xformBefore); + Ember.addListener(obj, beforeEvent(path), target, method, xform); Ember.watch(obj, path); return this; }; @@ -215,7 +199,7 @@ Ember.removeBeforeObserver = function(obj, path, target, method) { Ember.notifyObservers = function(obj, keyName) { if (obj.isDestroying) { return; } - notifyObservers(obj, changeEvent(keyName)); + notifyObservers(obj, changeEvent(keyName), keyName); }; /** @private */ @@ -232,6 +216,6 @@ Ember.notifyBeforeObservers = function(obj, keyName) { } } - notifyObservers(obj, beforeEvent(keyName), forceNotification); + notifyObservers(obj, beforeEvent(keyName), keyName, forceNotification); };
false
Other
emberjs
ember.js
d1b5d49ef8aecc3967fdbaff3156221fa48d061a.json
remove obscure feature of addObserver
packages/ember-metal/lib/observer.js
@@ -153,20 +153,14 @@ function beforeKey(eventName) { } /** @private */ -function xformForArgs(args) { - return function (target, method, params) { - var obj = params[0], keyName = changeKey(params[1]), val; - var copy_args = args.slice(); - if (method.length>2) { - val = Ember.getPath(Ember.isGlobalPath(keyName) ? window : obj, keyName); - } - copy_args.unshift(obj, keyName, val); - method.apply(target, copy_args); - }; +function xformChange(target, method, params) { + var obj = params[0], keyName = changeKey(params[1]), val; + if (method.length>2) { + val = Ember.getPath(Ember.isGlobalPath(keyName) ? window : obj, keyName); + } + method.apply(target, [obj, keyName, val]); } -var xformChange = xformForArgs([]); - /** @private */ function xformBefore(target, method, params) { var obj = params[0], keyName = beforeKey(params[1]), val; @@ -175,14 +169,7 @@ function xformBefore(target, method, params) { } Ember.addObserver = function(obj, path, target, method) { - var xform; - if (arguments.length > 4) { - var args = array_Slice.call(arguments, 4); - xform = xformForArgs(args); - } else { - xform = xformChange; - } - Ember.addListener(obj, changeEvent(path), target, method, xform); + Ember.addListener(obj, changeEvent(path), target, method, xformChange); Ember.watch(obj, path); return this; };
true
Other
emberjs
ember.js
d1b5d49ef8aecc3967fdbaff3156221fa48d061a.json
remove obscure feature of addObserver
packages/ember-metal/tests/observer_test.js
@@ -267,30 +267,6 @@ testBoth('addObserver should respect targets with methods', function(get,set){ }); -testBoth('addObserver should preserve additional context passed when firing the observer', function(get, set) { - var observed = { foo: 'foo' }; - - var target1 = { - count: 0, - - didChange: function(obj, keyName, value, ctx1, ctx2) { - equal(ctx1, "biff", "first context is passed"); - equal(ctx2, "bang", "second context is passed"); - equal(5, arguments.length); - this.count++; - } - }; - - Ember.addObserver(observed, 'foo', target1, 'didChange', "biff", "bang"); - - set(observed, 'foo', 'BAZ'); - equal(target1.count, 1, 'target1 observer should have fired'); - - set(observed, 'foo', 'BAZ2'); - equal(target1.count, 2, 'target1 observer should have fired'); -}); - - testBoth('addObserver should allow multiple objects to observe a property', function(get, set) { var observed = { foo: 'foo' }; var target1 = {
true
Other
emberjs
ember.js
ced3ad465c50f0448427587403b6418a3f378299.json
unify xform @enumerable edition
packages/ember-runtime/lib/mixins/enumerable.js
@@ -41,7 +41,8 @@ function iter(key, value) { /** @private */ function xform(target, method, params) { - method.call(target, params[0], params[2], params[3]); + var args = [].slice.call(params, 2); + method.apply(target, args); } /** @@ -707,7 +708,7 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ { Ember.propertyWillChange(this, '[]'); if (hasDelta) Ember.propertyWillChange(this, 'length'); - Ember.sendEvent(this, '@enumerable:before', removing, adding); + Ember.sendEvent(this, '@enumerable:before', this, removing, adding); return this; }, @@ -749,7 +750,7 @@ Ember.Enumerable = Ember.Mixin.create( /** @lends Ember.Enumerable */ { if (removing === -1) removing = null; if (adding === -1) adding = null; - Ember.sendEvent(this, '@enumerable:change', removing, adding); + Ember.sendEvent(this, '@enumerable:change', this, removing, adding); if (hasDelta) Ember.propertyDidChange(this, 'length'); Ember.propertyDidChange(this, '[]');
false
Other
emberjs
ember.js
5769c87030d257cd33faba9070bc58f1fed344ac.json
unify xform @array edition
packages/ember-runtime/lib/mixins/array.js
@@ -17,7 +17,8 @@ function none(obj) { return obj===null || obj===undefined; } /** @private */ function xform(target, method, params) { - method.call(target, params[0], params[2], params[3], params[4]); + var args = [].slice.call(params, 2); + method.apply(target, args); } // .......................................................... @@ -328,7 +329,7 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot if (addAmt === undefined) addAmt=-1; } - Ember.sendEvent(this, '@array:before', startIdx, removeAmt, addAmt); + Ember.sendEvent(this, '@array:before', this, startIdx, removeAmt, addAmt); var removing, lim; if (startIdx>=0 && removeAmt>=0 && get(this, 'hasEnumerableObservers')) { @@ -368,7 +369,7 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot } this.enumerableContentDidChange(removeAmt, adding); - Ember.sendEvent(this, '@array:change', startIdx, removeAmt, addAmt); + Ember.sendEvent(this, '@array:change', this, startIdx, removeAmt, addAmt); var length = get(this, 'length'), cachedFirst = cacheFor(this, 'firstObject'),
false
Other
emberjs
ember.js
5ac298f764f417d64bfd8e7b85322bfcdcd7940e.json
remove unused var
packages/ember-runtime/lib/system/core_object.js
@@ -32,7 +32,7 @@ function makeCtor() { // method a lot faster. This is glue code so we want it to be as fast as // possible. - var wasApplied = false, initMixins, init = false; + var wasApplied = false, initMixins; var Class = function() { if (!wasApplied) {
false
Other
emberjs
ember.js
fd4e1067999e6d9428ff86e8941863102ed57819.json
remove memory leak of anonymous subclasses
packages/ember-runtime/lib/system/core_object.js
@@ -183,10 +183,6 @@ var ClassMixin = Ember.Mixin.create( Ember.generateGuid(proto, 'ember'); meta(proto).proto = proto; // this will disable observers on prototype - - Class.subclasses = Ember.Set ? new Ember.Set() : null; - if (this.subclasses) { this.subclasses.add(Class); } - Class.ClassMixin.apply(Class); return Class; },
true
Other
emberjs
ember.js
fd4e1067999e6d9428ff86e8941863102ed57819.json
remove memory leak of anonymous subclasses
packages/ember-runtime/lib/system/object.js
@@ -8,8 +8,6 @@ require('ember-runtime/mixins/observable'); require('ember-runtime/system/core_object'); require('ember-runtime/system/set'); -Ember.CoreObject.subclasses = new Ember.Set(); - /** @class @@ -21,6 +19,3 @@ Ember.CoreObject.subclasses = new Ember.Set(); @extends Ember.Observable */ Ember.Object = Ember.CoreObject.extend(Ember.Observable); - - -
true
Other
emberjs
ember.js
fd4e1067999e6d9428ff86e8941863102ed57819.json
remove memory leak of anonymous subclasses
packages/ember-runtime/tests/legacy_1x/system/object/base_test.js
@@ -157,12 +157,3 @@ test("Checking the detectInstance() function on an object and its subclass", fun ok(Ember.Object.detectInstance(obj.create())); ok(obj.detectInstance(obj.create())); }); - -test("subclasses should contain defined subclasses", function() { - ok(inArray(obj1, obj.subclasses) > -1, 'obj.subclasses should contain obj1'); - - equal(get(obj1.subclasses, 'length'),0,'obj1.subclasses should be empty'); - - var kls2 = obj1.extend(); - ok(inArray(kls2, obj1.subclasses) > -1, 'obj1.subclasses should contain kls2'); -});
true
Other
emberjs
ember.js
fd4e1067999e6d9428ff86e8941863102ed57819.json
remove memory leak of anonymous subclasses
packages/ember-runtime/tests/system/object/subclasses_test.js
@@ -6,23 +6,6 @@ module('system/object/subclasses'); -test('Ember.Object should have a subclass set', function() { - ok(Ember.Object.subclasses instanceof Ember.Set); -}); - -test('defining a new subclass should add it to set of parent', function() { - var Subclass = Ember.Object.extend(); - ok(Ember.Object.subclasses.contains(Subclass)); -}); - -test('defining sub-sub class should only go to parent', function() { - var Sub = Ember.Object.extend(); - var SubSub = Sub.extend(); - - ok(Ember.Object.subclasses.contains(Sub), 'Ember.Object contains Sub'); - ok(Sub.subclasses.contains(SubSub), 'Sub contains SubSub'); -}); - // TEST lazy prototype and Em.rewatch(prototype) test('chains should copy forward to subclasses when prototype created', function () { var ObjectWithChains, objWithChains, SubWithChains, SubSub, subSub;
true
Other
emberjs
ember.js
2d26a36f4119ffa0f8b41157dbb2856f27a33420.json
Improve the sorting algorithm for routing If one route is an explicit substring of another, prefer the longer one. Otherwise, if one of the routes has a dynamic segment, prefer the route without the dynamic segment. Otherwise, prefer the longer one. This fixes posts/:post_id being preferred over posts/new. Eventually, we should prebuild the match tree.
packages/ember-routing/lib/routable.js
@@ -260,6 +260,21 @@ Ember.Routable = Ember.Mixin.create({ var childStates = get(this, 'childStates'), match; childStates = childStates.sort(function(a, b) { + var aDynamicSegments = getPath(a, 'routeMatcher.identifiers.length'), + bDynamicSegments = getPath(b, 'routeMatcher.identifiers.length'), + aRoute = get(a, 'route'), + bRoute = get(b, 'route'); + + if (aRoute.indexOf(bRoute) === 0) { + return -1; + } else if (bRoute.indexOf(aRoute) === 0) { + return 1; + } + + if (aDynamicSegments !== bDynamicSegments) { + return aDynamicSegments - bDynamicSegments; + } + return getPath(b, 'route.length') - getPath(a, 'route.length'); });
false
Other
emberjs
ember.js
6c428ec4a890d8e2e58e545d503995b46c327f5f.json
Move initial observer setup to finishPartial
packages/ember-metal/lib/mixin.js
@@ -191,6 +191,31 @@ function connectBindings(obj, m) { } } +function applyObservers(obj) { + var meta = Ember.meta(obj), + observers = meta.observers, + beforeObservers = meta.beforeObservers, + methodName, method, observerPaths, i, l; + + for (methodName in observers) { + method = observers[methodName]; + observerPaths = getObserverPaths(method); + + for (i=0, l=observerPaths.length; i<l; i++) { + Ember.addObserver(obj, observerPaths[i], null, methodName); + } + } + + for (methodName in beforeObservers) { + method = beforeObservers[methodName]; + observerPaths = getBeforeObserverPaths(method); + + for (i=0, l=observerPaths.length; i<l; i++) { + Ember.addBeforeObserver(obj, observerPaths[i], null, methodName); + } + } +} + /** @private */ function applyMixin(obj, mixins, partial) { var descs = {}, values = {}, m = Ember.meta(obj), req = m.required, @@ -242,46 +267,15 @@ function applyMixin(obj, mixins, partial) { if (desc === undefined && value === undefined) { continue; } if (willApply) { willApply.call(obj, key); } - // If an observer replaces an existing superclass observer, - // remove the superclass observers. - var observerPaths = getObserverPaths(value), - curObserverPaths = observerPaths && getObserverPaths(obj[key]), - beforeObserverPaths = getBeforeObserverPaths(value), - curBeforeObserverPaths = beforeObserverPaths && getBeforeObserverPaths(obj[key]), - len, idx; - - if (curObserverPaths) { - len = curObserverPaths.length; - for (idx=0; idx < len; idx++) { - Ember.removeObserver(obj, curObserverPaths[idx], null, key); - } - } + var hasObservers = getObserverPaths(value), + hasBeforeObservers = getBeforeObserverPaths(value); - if (curBeforeObserverPaths) { - len = curBeforeObserverPaths.length; - for (idx=0; idx < len; idx++) { - Ember.removeBeforeObserver(obj, curBeforeObserverPaths[idx], null, key); - } - } + if (hasObservers) { m.observers[key] = value; } + if (hasBeforeObservers) { m.beforeObservers[key] = value; } detectBinding(obj, key, m); - Ember.defineProperty(obj, key, desc, value); - if (observerPaths) { - len = observerPaths.length; - for(idx=0; idx < len; idx++) { - Ember.addObserver(obj, observerPaths[idx], null, key); - } - } - - if (beforeObserverPaths) { - len = beforeObserverPaths.length; - for(idx=0; idx < len; idx++) { - Ember.addBeforeObserver(obj, beforeObserverPaths[idx], null, key); - } - } - if (req && req[key]) { req = writableReq(obj); req.__ember_count__--; @@ -292,9 +286,9 @@ function applyMixin(obj, mixins, partial) { } } - if (!partial) { // don't apply to prototype - value = connectBindings(obj, m); - } + //if (!partial) { // don't apply to prototype + //value = connectBindings(obj, m); + //} // Make sure no required attrs remain if (!partial && req && req.__ember_count__>0) { @@ -311,7 +305,9 @@ function applyMixin(obj, mixins, partial) { Ember.mixin = function(obj) { var args = a_slice.call(arguments, 1); - return applyMixin(obj, args, false); + applyMixin(obj, args, false); + Mixin.finishPartial(obj); + return obj; }; /** @@ -355,6 +351,7 @@ Mixin.applyPartial = function(obj) { Mixin.finishPartial = function(obj) { connectBindings(obj); + applyObservers(obj); return obj; }; @@ -396,19 +393,15 @@ MixinPrototype.reopen = function() { return this; }; -var TMP_ARRAY = []; MixinPrototype.apply = function(obj) { - TMP_ARRAY[0] = this; - var ret = applyMixin(obj, TMP_ARRAY, false); - TMP_ARRAY.length=0; - return ret; + applyMixin(obj, [this], false); + Mixin.finishPartial(obj); + return obj; }; MixinPrototype.applyPartial = function(obj) { - TMP_ARRAY[0] = this; - var ret = applyMixin(obj, TMP_ARRAY, true); - TMP_ARRAY.length=0; - return ret; + applyMixin(obj, [this], true); + return obj; }; /** @private */
true
Other
emberjs
ember.js
6c428ec4a890d8e2e58e545d503995b46c327f5f.json
Move initial observer setup to finishPartial
packages/ember-metal/lib/utils.js
@@ -174,6 +174,8 @@ Ember.meta = function meta(obj, writable) { ret = obj[META_KEY] = createMeta({ descs: {}, watching: {}, + observers: {}, + beforeObservers: {}, values: {}, lastSetValues: {}, cache: {}, @@ -188,6 +190,8 @@ Ember.meta = function meta(obj, writable) { ret.descs = o_create(ret.descs); ret.values = o_create(ret.values); ret.watching = o_create(ret.watching); + ret.observers = o_create(ret.observers); + ret.beforeObservers = o_create(ret.beforeObservers); ret.lastSetValues = {}; ret.cache = {}; ret.source = obj;
true
Other
emberjs
ember.js
ce3eb53997ce3f451d2a29989d06775e7ba4cdff.json
add observers wiring to finishPartial
packages/ember-metal/lib/mixin.js
@@ -144,21 +144,10 @@ function writableReq(obj) { return req; } -/** @private */ -function getObserverPaths(value) { - return 'function' === typeof value && value.__ember_observes__; -} - -/** @private */ -function getBeforeObserverPaths(value) { - return 'function' === typeof value && value.__ember_observesBefore__; -} - var IS_BINDING = Ember.IS_BINDING = /^.+Binding$/; - /** @private */ -function detectBinding(obj, key, m) { +function detectBinding(obj, key, value, m) { if (IS_BINDING.test(key)) { var bindings = m.bindings; if (!bindings) { @@ -167,28 +156,77 @@ function detectBinding(obj, key, m) { bindings = m.bindings = o_create(m.bindings); bindings.__emberproto__ = obj; } - bindings[key] = true; + bindings[key] = value; } } /** @private */ function connectBindings(obj, m) { - var bindings = (m || Ember.meta(obj)).bindings, key, binding; + // TODO Mixin.apply(instance) should disconnect binding if exists + var bindings = m.bindings, key, binding, to; if (bindings) { for (key in bindings) { - binding = key !== '__emberproto__' && obj[key]; + binding = key !== '__emberproto__' && bindings[key]; if (binding) { + to = key.slice(0, -7); // strip Binding off end if (binding instanceof Ember.Binding) { binding = binding.copy(); // copy prototypes' instance - binding.to(key.slice(0, -7)); - } else { - binding = new Ember.Binding(key.slice(0, -7), binding); + binding.to(to); + } else { // binding is string path + binding = new Ember.Binding(to, binding); } binding.connect(obj); obj[key] = binding; } } + // mark as applied + m.bindings = { __emberproto__: obj }; + } +} + +var addObserver = Ember.addObserver, + addBeforeObserver = Ember.addBeforeObserver; + +function applyBeforeObservers(obj, m) { + // TODO Mixin.apply should removeBeforeObserver if exists + var beforeObservers = m.beforeObservers, + methodName, method, paths, i, l; + + for (methodName in beforeObservers) { + method = beforeObservers[methodName]; + paths = method.__ember_observesBefore__; + for (i=0, l=paths.length; i<l; i++) { + addBeforeObserver(obj, paths[i], obj, method); + } + } + + // mark as applied for future Mixin.apply() + m.beforeObservers = {}; +} + +function applyObservers(obj, m) { + // TODO Mixin.apply should removeObserver if exists + var observers = m.observers, + methodName, method, paths, i, l; + + for (methodName in observers) { + method = observers[methodName]; + paths = method.__ember_observes__; + for (i=0, l=paths.length; i<l; i++) { + addObserver(obj, paths[i], obj, method); + } } + + // mark as applied for future Mixin.apply() + m.beforeObservers = {}; +} + +function finishPartial(obj, m) { + m = m || Ember.meta(obj); + applyBeforeObservers(obj, m); + applyObservers(obj, m); + connectBindings(obj, m); + return obj; } /** @private */ @@ -242,46 +280,17 @@ function applyMixin(obj, mixins, partial) { if (desc === undefined && value === undefined) { continue; } if (willApply) { willApply.call(obj, key); } - // If an observer replaces an existing superclass observer, - // remove the superclass observers. - var observerPaths = getObserverPaths(value), - curObserverPaths = observerPaths && getObserverPaths(obj[key]), - beforeObserverPaths = getBeforeObserverPaths(value), - curBeforeObserverPaths = beforeObserverPaths && getBeforeObserverPaths(obj[key]), - len, idx; - - if (curObserverPaths) { - len = curObserverPaths.length; - for (idx=0; idx < len; idx++) { - Ember.removeObserver(obj, curObserverPaths[idx], null, key); - } - } - - if (curBeforeObserverPaths) { - len = curBeforeObserverPaths.length; - for (idx=0; idx < len; idx++) { - Ember.removeBeforeObserver(obj, curBeforeObserverPaths[idx], null, key); + if ('function' === typeof value) { + if (value.__ember_observesBefore__) { + m.beforeObservers[key] = value; + } else if (value.__ember_observes__) { + m.observers[key] = value; } } - detectBinding(obj, key, m); - + detectBinding(obj, key, value, m); Ember.defineProperty(obj, key, desc, value); - if (observerPaths) { - len = observerPaths.length; - for(idx=0; idx < len; idx++) { - Ember.addObserver(obj, observerPaths[idx], null, key); - } - } - - if (beforeObserverPaths) { - len = beforeObserverPaths.length; - for(idx=0; idx < len; idx++) { - Ember.addBeforeObserver(obj, beforeObserverPaths[idx], null, key); - } - } - if (req && req[key]) { req = writableReq(obj); req.__ember_count__--; @@ -293,7 +302,7 @@ function applyMixin(obj, mixins, partial) { } if (!partial) { // don't apply to prototype - value = connectBindings(obj, m); + finishPartial(obj, m); } // Make sure no required attrs remain @@ -353,10 +362,7 @@ Mixin.applyPartial = function(obj) { return applyMixin(obj, args, true); }; -Mixin.finishPartial = function(obj) { - connectBindings(obj); - return obj; -}; +Mixin.finishPartial = finishPartial; Mixin.create = function() { classToString.processed = false;
true
Other
emberjs
ember.js
ce3eb53997ce3f451d2a29989d06775e7ba4cdff.json
add observers wiring to finishPartial
packages/ember-metal/lib/utils.js
@@ -175,6 +175,8 @@ Ember.meta = function meta(obj, writable) { descs: {}, watching: {}, values: {}, + observers: {}, + beforeObservers: {}, lastSetValues: {}, cache: {}, source: obj @@ -188,6 +190,8 @@ Ember.meta = function meta(obj, writable) { ret.descs = o_create(ret.descs); ret.values = o_create(ret.values); ret.watching = o_create(ret.watching); + ret.observers = o_create(ret.observers); + ret.beforeObservers = o_create(ret.beforeObservers); ret.lastSetValues = {}; ret.cache = {}; ret.source = obj;
true
Other
emberjs
ember.js
ce3eb53997ce3f451d2a29989d06775e7ba4cdff.json
add observers wiring to finishPartial
packages/ember-metal/tests/observer_test.js
@@ -355,7 +355,7 @@ testBoth('local observers can be removed', function(get, set) { set(obj, 'bar', 'HI!'); equal(barObserved, 2, 'precond - observers should be fired'); - Ember.removeObserver(obj, 'bar', null, 'foo1'); + Ember.removeObserver(obj, 'bar', obj, obj.foo1); barObserved = 0; set(obj, 'bar', 'HI AGAIN!');
true
Other
emberjs
ember.js
ce3eb53997ce3f451d2a29989d06775e7ba4cdff.json
add observers wiring to finishPartial
packages/ember-metal/tests/watching/isWatching_test.js
@@ -22,7 +22,7 @@ test("isWatching is true for regular local observers", function() { didChange: Ember.observer(fn, key) }).apply(obj); }, function(obj, key, fn) { - Ember.removeObserver(obj, key, null, fn); + Ember.removeObserver(obj, key, obj, fn); }); });
true
Other
emberjs
ember.js
ce3eb53997ce3f451d2a29989d06775e7ba4cdff.json
add observers wiring to finishPartial
packages/ember-runtime/tests/ext/mixin_test.js
@@ -8,7 +8,6 @@ module('system/mixin/binding_test'); test('Defining a property ending in Binding should setup binding when applied', function() { - var MyMixin = Ember.Mixin.create({ fooBinding: 'bar.baz' });
true
Other
emberjs
ember.js
5de4da062376ef955677d435d721cbeb8712e9eb.json
Improve some assertion messages
packages/ember-handlebars/lib/helpers/collection.js
@@ -135,7 +135,7 @@ Ember.Handlebars.registerHelper('collection', function(path, options) { // Otherwise, just default to the standard class. var collectionClass; collectionClass = path ? getPath(this, path, options) : Ember.CollectionView; - Ember.assert(fmt("%@ #collection: Could not find %@", data.view, path), !!collectionClass); + Ember.assert(fmt("%@ #collection: Could not find collection class %@", [data.view, path]), !!collectionClass); var hash = options.hash, itemHash = {}, match; @@ -144,7 +144,7 @@ Ember.Handlebars.registerHelper('collection', function(path, options) { var collectionPrototype = collectionClass.proto(); delete hash.itemViewClass; itemViewClass = itemViewPath ? getPath(collectionPrototype, itemViewPath, options) : collectionPrototype.itemViewClass; - Ember.assert(fmt("%@ #collection: Could not find %@", data.view, itemViewPath), !!itemViewClass); + Ember.assert(fmt("%@ #collection: Could not find itemViewClass %@", [data.view, itemViewPath]), !!itemViewClass); // Go through options passed to the {{collection}} helper and extract options // that configure item views instead of the collection itself.
true
Other
emberjs
ember.js
5de4da062376ef955677d435d721cbeb8712e9eb.json
Improve some assertion messages
packages/ember-views/lib/views/view.js
@@ -794,7 +794,7 @@ Ember.View = Ember.Object.extend(Ember.Evented, // is the view by default. A hash of data is also passed that provides // the template with access to the view and render buffer. - Ember.assert('template must be a function. Did you mean to specify templateName instead?', typeof template === 'function'); + Ember.assert('template must be a function. Did you mean to call Ember.Handlebars.compile("...") or specify templateName instead?', typeof template === 'function'); // The template should write directly to the render buffer instead // of returning a string. var output = template(context, { data: data });
true
Other
emberjs
ember.js
e945b9ebde480f642017e4ecea6c545014f68741.json
Update location documentation
packages/ember-application/lib/system/location.js
@@ -8,6 +8,7 @@ var get = Ember.get, set = Ember.set; getURL: returns the current URL setURL(path): sets the current URL onUpdateURL(callback): triggers the callback when the URL changes + formatURL(url): formats `url` to be placed into `href` attribute Calling setURL will not trigger onUpdateURL callbacks.
false
Other
emberjs
ember.js
11211994fe735900b4d6ccbfed9eacf528fd3f8b.json
Fix spelling of Handlebars
packages/ember-handlebars/lib/controls.js
@@ -1,5 +1,5 @@ // ========================================================================== -// Project: Ember Handlebar Views +// Project: Ember Handlebars Views // Copyright: ©2011 Strobe Inc. and contributors. // License: Licensed under MIT license (see license.js) // ==========================================================================
true
Other
emberjs
ember.js
11211994fe735900b4d6ccbfed9eacf528fd3f8b.json
Fix spelling of Handlebars
packages/ember-handlebars/lib/controls/button.js
@@ -1,5 +1,5 @@ // ========================================================================== -// Project: Ember Handlebar Views +// Project: Ember Handlebars Views // Copyright: ©2011 Strobe Inc. and contributors. // License: Licensed under MIT license (see license.js) // ==========================================================================
true
Other
emberjs
ember.js
11211994fe735900b4d6ccbfed9eacf528fd3f8b.json
Fix spelling of Handlebars
packages/ember-handlebars/lib/controls/checkbox.js
@@ -1,5 +1,5 @@ // ========================================================================== -// Project: Ember Handlebar Views +// Project: Ember Handlebars Views // Copyright: ©2011 Strobe Inc. and contributors. // License: Licensed under MIT license (see license.js) // ==========================================================================
true
Other
emberjs
ember.js
11211994fe735900b4d6ccbfed9eacf528fd3f8b.json
Fix spelling of Handlebars
packages/ember-handlebars/lib/controls/text_area.js
@@ -1,5 +1,5 @@ // ========================================================================== -// Project: Ember Handlebar Views +// Project: Ember Handlebars Views // Copyright: ©2011 Strobe Inc. and contributors. // License: Licensed under MIT license (see license.js) // ==========================================================================
true
Other
emberjs
ember.js
11211994fe735900b4d6ccbfed9eacf528fd3f8b.json
Fix spelling of Handlebars
packages/ember-handlebars/lib/controls/text_field.js
@@ -1,5 +1,5 @@ // ========================================================================== -// Project: Ember Handlebar Views +// Project: Ember Handlebars Views // Copyright: ©2011 Strobe Inc. and contributors. // License: Licensed under MIT license (see license.js) // ==========================================================================
true
Other
emberjs
ember.js
11211994fe735900b4d6ccbfed9eacf528fd3f8b.json
Fix spelling of Handlebars
packages/ember-handlebars/lib/controls/text_support.js
@@ -1,5 +1,5 @@ // ========================================================================== -// Project: Ember Handlebar Views +// Project: Ember Handlebars Views // Copyright: ©2011 Strobe Inc. and contributors. // License: Licensed under MIT license (see license.js) // ==========================================================================
true
Other
emberjs
ember.js
11211994fe735900b4d6ccbfed9eacf528fd3f8b.json
Fix spelling of Handlebars
packages/ember-handlebars/lib/ext.js
@@ -1,5 +1,5 @@ // ========================================================================== -// Project: Ember Handlebar Views +// Project: Ember Handlebars Views // Copyright: ©2011 Strobe Inc. and contributors. // License: Licensed under MIT license (see license.js) // ==========================================================================
true
Other
emberjs
ember.js
11211994fe735900b4d6ccbfed9eacf528fd3f8b.json
Fix spelling of Handlebars
packages/ember-handlebars/lib/helpers.js
@@ -1,5 +1,5 @@ // ========================================================================== -// Project: Ember Handlebar Views +// Project: Ember Handlebars Views // Copyright: ©2011 Strobe Inc. and contributors. // License: Licensed under MIT license (see license.js) // ==========================================================================
true
Other
emberjs
ember.js
11211994fe735900b4d6ccbfed9eacf528fd3f8b.json
Fix spelling of Handlebars
packages/ember-handlebars/lib/helpers/binding.js
@@ -1,5 +1,5 @@ // ========================================================================== -// Project: Ember Handlebar Views +// Project: Ember Handlebars Views // Copyright: ©2011 Strobe Inc. and contributors. // License: Licensed under MIT license (see license.js) // ==========================================================================
true
Other
emberjs
ember.js
11211994fe735900b4d6ccbfed9eacf528fd3f8b.json
Fix spelling of Handlebars
packages/ember-handlebars/lib/helpers/collection.js
@@ -1,5 +1,5 @@ // ========================================================================== -// Project: Ember Handlebar Views +// Project: Ember Handlebars Views // Copyright: ©2011 Strobe Inc. and contributors. // License: Licensed under MIT license (see license.js) // ==========================================================================
true
Other
emberjs
ember.js
11211994fe735900b4d6ccbfed9eacf528fd3f8b.json
Fix spelling of Handlebars
packages/ember-handlebars/lib/helpers/debug.js
@@ -1,5 +1,5 @@ // ========================================================================== -// Project: Ember Handlebar Views +// Project: Ember Handlebars Views // Copyright: ©2011 Strobe Inc. and contributors. // License: Licensed under MIT license (see license.js) // ==========================================================================
true
Other
emberjs
ember.js
11211994fe735900b4d6ccbfed9eacf528fd3f8b.json
Fix spelling of Handlebars
packages/ember-handlebars/lib/helpers/unbound.js
@@ -1,5 +1,5 @@ // ========================================================================== -// Project: Ember Handlebar Views +// Project: Ember Handlebars Views // Copyright: ©2011 Strobe Inc. and contributors. // License: Licensed under MIT license (see license.js) // ==========================================================================
true
Other
emberjs
ember.js
11211994fe735900b4d6ccbfed9eacf528fd3f8b.json
Fix spelling of Handlebars
packages/ember-handlebars/lib/helpers/view.js
@@ -1,5 +1,5 @@ // ========================================================================== -// Project: Ember Handlebar Views +// Project: Ember Handlebars Views // Copyright: ©2011 Strobe Inc. and contributors. // License: Licensed under MIT license (see license.js) // ==========================================================================
true
Other
emberjs
ember.js
11211994fe735900b4d6ccbfed9eacf528fd3f8b.json
Fix spelling of Handlebars
packages/ember-handlebars/lib/loader.js
@@ -1,5 +1,5 @@ // ========================================================================== -// Project: Ember Handlebar Views +// Project: Ember Handlebars Views // Copyright: ©2011 Strobe Inc. and contributors. // License: Licensed under MIT license (see license.js) // ==========================================================================
true
Other
emberjs
ember.js
11211994fe735900b4d6ccbfed9eacf528fd3f8b.json
Fix spelling of Handlebars
packages/ember-handlebars/lib/main.js
@@ -1,5 +1,5 @@ // ========================================================================== -// Project: Ember Handlebar Views +// Project: Ember Handlebars Views // Copyright: ©2011 Strobe Inc. and contributors. // License: Licensed under MIT license (see license.js) // ==========================================================================
true
Other
emberjs
ember.js
11211994fe735900b4d6ccbfed9eacf528fd3f8b.json
Fix spelling of Handlebars
packages/ember-handlebars/lib/views.js
@@ -1,5 +1,5 @@ // ========================================================================== -// Project: Ember Handlebar Views +// Project: Ember Handlebars Views // Copyright: ©2011 Strobe Inc. and contributors. // License: Licensed under MIT license (see license.js) // ==========================================================================
true
Other
emberjs
ember.js
11211994fe735900b4d6ccbfed9eacf528fd3f8b.json
Fix spelling of Handlebars
packages/ember-handlebars/lib/views/handlebars_bound_view.js
@@ -1,5 +1,5 @@ // ========================================================================== -// Project: Ember Handlebar Views +// Project: Ember Handlebars Views // Copyright: ©2011 Strobe Inc. and contributors. // License: Licensed under MIT license (see license.js) // ==========================================================================
true
Other
emberjs
ember.js
11211994fe735900b4d6ccbfed9eacf528fd3f8b.json
Fix spelling of Handlebars
packages/ember-handlebars/tests/controls/button_test.js
@@ -1,5 +1,5 @@ // ========================================================================== -// Project: Ember Handlebar Views +// Project: Ember Handlebars Views // Copyright: ©2011 Strobe Inc. and contributors. // License: Licensed under MIT license (see license.js) // ==========================================================================
true
Other
emberjs
ember.js
11211994fe735900b4d6ccbfed9eacf528fd3f8b.json
Fix spelling of Handlebars
packages/ember-handlebars/tests/controls/checkbox_test.js
@@ -1,5 +1,5 @@ // ========================================================================== -// Project: Ember Handlebar Views +// Project: Ember Handlebars Views // Copyright: ©2011 Strobe Inc. and contributors. // License: Licensed under MIT license (see license.js) // ==========================================================================
true
Other
emberjs
ember.js
11211994fe735900b4d6ccbfed9eacf528fd3f8b.json
Fix spelling of Handlebars
packages/ember-handlebars/tests/controls/text_area_test.js
@@ -1,5 +1,5 @@ // ========================================================================== -// Project: Ember Handlebar Views +// Project: Ember Handlebars Views // Copyright: ©2011 Strobe Inc. and contributors. // License: Licensed under MIT license (see license.js) // ==========================================================================
true
Other
emberjs
ember.js
11211994fe735900b4d6ccbfed9eacf528fd3f8b.json
Fix spelling of Handlebars
packages/ember-handlebars/tests/controls/text_field_test.js
@@ -1,5 +1,5 @@ // ========================================================================== -// Project: Ember Handlebar Views +// Project: Ember Handlebars Views // Copyright: ©2011 Strobe Inc. and contributors. // License: Licensed under MIT license (see license.js) // ==========================================================================
true
Other
emberjs
ember.js
11211994fe735900b4d6ccbfed9eacf528fd3f8b.json
Fix spelling of Handlebars
packages/ember-handlebars/tests/handlebars_test.js
@@ -1,5 +1,5 @@ // ========================================================================== -// Project: Ember Handlebar Views +// Project: Ember Handlebars Views // Copyright: ©2011 Strobe Inc. and contributors. // License: Licensed under MIT license (see license.js) // ==========================================================================
true
Other
emberjs
ember.js
11211994fe735900b4d6ccbfed9eacf528fd3f8b.json
Fix spelling of Handlebars
packages/ember-handlebars/tests/helpers/yield_test.js
@@ -1,5 +1,5 @@ // ========================================================================== -// Project: Ember Handlebar Views +// Project: Ember Handlebars Views // Copyright: ©2011 Strobe Inc. and contributors. // License: Licensed under MIT license (see license.js) // ==========================================================================
true
Other
emberjs
ember.js
11211994fe735900b4d6ccbfed9eacf528fd3f8b.json
Fix spelling of Handlebars
packages/ember-handlebars/tests/views/collection_view_test.js
@@ -1,5 +1,5 @@ // ========================================================================== -// Project: Ember Handlebar Views +// Project: Ember Handlebars Views // Copyright: ©2011 Strobe Inc. and contributors. // License: Licensed under MIT license (see license.js) // ========================================================================== @@ -239,7 +239,7 @@ test("should give its item views the property specified by itemPropertyBinding", tagName: 'li' }); - // Use preserveContext=false so the itemView handlebar context is the view context + // Use preserveContext=false so the itemView handlebars context is the view context // Set itemView bindings using item* var view = Ember.View.create({ baz: "baz",
true
Other
emberjs
ember.js
960bbe09227e27517ead710dd12bb9136aaa2d66.json
Modify run loop behavior. We want to restart the run loop to flush prior queues before moving on to the next queue.
packages/ember-metal/lib/run_loop.js
@@ -85,9 +85,9 @@ RunLoop.prototype = { }, flush: function(queueName) { - var queues = this._queues, queueNames, idx, len, queue, log; + var queueNames, idx, len, queue, log; - if (!queues) { return this; } // nothing to do + if (!this._queues) { return this; } // nothing to do function iter(item) { invoke(item.target, item.method, item.args); @@ -122,33 +122,45 @@ RunLoop.prototype = { } else { queueNames = Ember.run.queues; len = queueNames.length; - do { - this._queues = null; - for (idx=0; idx < len; idx++) { - queueName = queueNames[idx]; - queue = queues[queueName]; - - if (queue) { - // the sync phase is to allow property changes to propagate. don't - // invoke observers until that is finished. - if (queueName === 'sync') { - log = Ember.LOG_BINDINGS; - if (log) { Ember.Logger.log('Begin: Flush Sync Queue'); } - - Ember.beginPropertyChanges(); - try { - forEach.call(queue, iter); - } finally { - Ember.endPropertyChanges(); - } - - if (log) { Ember.Logger.log('End: Flush Sync Queue'); } - } else { + idx = 0; + + outerloop: + while (idx < len) { + queueName = queueNames[idx]; + queue = this._queues && this._queues[queueName]; + delete this._queues[queueName]; + + if (queue) { + // the sync phase is to allow property changes to propagate. don't + // invoke observers until that is finished. + if (queueName === 'sync') { + log = Ember.LOG_BINDINGS; + if (log) { Ember.Logger.log('Begin: Flush Sync Queue'); } + + Ember.beginPropertyChanges(); + try { forEach.call(queue, iter); + } finally { + Ember.endPropertyChanges(); } + + if (log) { Ember.Logger.log('End: Flush Sync Queue'); } + } else { + forEach.call(queue, iter); } } - } while (queues = this._queues); // go until queues stay clean + + // Loop through prior queues + for (var i = 0; i <= idx; i++) { + if (this._queues && this._queues[queueNames[i]]) { + // Start over at the first queue with contents + idx = i; + continue outerloop; + } + } + + idx++; + } } timerMark = null;
true
Other
emberjs
ember.js
960bbe09227e27517ead710dd12bb9136aaa2d66.json
Modify run loop behavior. We want to restart the run loop to flush prior queues before moving on to the next queue.
packages/ember-metal/tests/run_loop/schedule_test.js
@@ -36,3 +36,27 @@ test('nested runs should queue each phase independently', function() { equal(cnt, 2, 'should flush actions now'); }); + +test('prior queues should be flushed before moving on to next queue', function() { + var order = []; + + Ember.run(function() { + Ember.run.schedule('sync', function() { + order.push('sync'); + }); + Ember.run.schedule('actions', function() { + order.push('actions'); + Ember.run.schedule('actions', function() { + order.push('actions'); + }); + Ember.run.schedule('sync', function() { + order.push('sync'); + }); + }); + Ember.run.schedule('timers', function() { + order.push('timers'); + }); + }); + + deepEqual(order, ['sync', 'actions', 'sync', 'actions', 'timers']); +});
true
Other
emberjs
ember.js
d6ef3990289357f26132418cf25b1ec4898814e7.json
Modify run loop behavior. We want to restart the run loop to flush prior queues before moving on to the next queue.
packages/ember-metal/lib/run_loop.js
@@ -86,9 +86,9 @@ RunLoop.prototype = { }, flush: function(queueName) { - var queues = this._queues, queueNames, idx, len, queue, log; + var queueNames, idx, len, queue, log; - if (!queues) { return this; } // nothing to do + if (!this._queues) { return this; } // nothing to do function iter(item) { invoke(item.target, item.method, item.args); @@ -123,33 +123,45 @@ RunLoop.prototype = { } else { queueNames = Ember.run.queues; len = queueNames.length; - do { - this._queues = null; - for (idx=0; idx < len; idx++) { - queueName = queueNames[idx]; - queue = queues[queueName]; - - if (queue) { - // the sync phase is to allow property changes to propagate. don't - // invoke observers until that is finished. - if (queueName === 'sync') { - log = Ember.LOG_BINDINGS; - if (log) { Ember.Logger.log('Begin: Flush Sync Queue'); } - - Ember.beginPropertyChanges(); - try { - forEach.call(queue, iter); - } finally { - Ember.endPropertyChanges(); - } - - if (log) { Ember.Logger.log('End: Flush Sync Queue'); } - } else { + idx = 0; + + outerloop: + while (idx < len) { + queueName = queueNames[idx]; + queue = this._queues && this._queues[queueName]; + delete this._queues[queueName]; + + if (queue) { + // the sync phase is to allow property changes to propagate. don't + // invoke observers until that is finished. + if (queueName === 'sync') { + log = Ember.LOG_BINDINGS; + if (log) { Ember.Logger.log('Begin: Flush Sync Queue'); } + + Ember.beginPropertyChanges(); + try { forEach.call(queue, iter); + } finally { + Ember.endPropertyChanges(); } + + if (log) { Ember.Logger.log('End: Flush Sync Queue'); } + } else { + forEach.call(queue, iter); } } - } while (queues = this._queues); // go until queues stay clean + + // Loop through prior queues + for (var i = 0; i <= idx; i++) { + if (this._queues && this._queues[queueNames[i]]) { + // Start over at the first queue with contents + idx = i; + continue outerloop; + } + } + + idx++; + } } timerMark = null;
true
Other
emberjs
ember.js
d6ef3990289357f26132418cf25b1ec4898814e7.json
Modify run loop behavior. We want to restart the run loop to flush prior queues before moving on to the next queue.
packages/ember-metal/tests/run_loop/schedule_test.js
@@ -36,3 +36,27 @@ test('nested runs should queue each phase independently', function() { equal(cnt, 2, 'should flush actions now'); }); + +test('prior queues should be flushed before moving on to next queue', function() { + var order = []; + + Ember.run(function() { + Ember.run.schedule('sync', function() { + order.push('sync'); + }); + Ember.run.schedule('actions', function() { + order.push('actions'); + Ember.run.schedule('actions', function() { + order.push('actions'); + }); + Ember.run.schedule('sync', function() { + order.push('sync'); + }); + }); + Ember.run.schedule('timers', function() { + order.push('timers'); + }); + }); + + deepEqual(order, ['sync', 'actions', 'sync', 'actions', 'timers']); +});
true
Other
emberjs
ember.js
79d6cbb214b98ac3faf39a373873dc40d6468806.json
Normalize path for binding {{#with as}}. Ref #980
packages/ember-handlebars/lib/helpers/binding.js
@@ -158,7 +158,7 @@ EmberHandlebars.registerHelper('boundIf', function(property, fn) { */ EmberHandlebars.registerHelper('with', function(context, options) { if (arguments.length === 4) { - var keywordName, path; + var keywordName, path, rootPath, normalized; Ember.assert("If you pass more than one argument to the with helper, it must be in the form #with foo as bar", arguments[1] === "as"); options = arguments[3]; @@ -170,10 +170,14 @@ EmberHandlebars.registerHelper('with', function(context, options) { if (Ember.isGlobal(path)) { Ember.bind(options.data.keywords, keywordName, path); } else { + normalized = normalizePath(this, path, options.data); + path = normalized.path; + rootPath = normalized.root; + // This is a workaround for the fact that you cannot bind separate objects // together. When we implement that functionality, we should use it here. - var contextKey = Ember.$.expando + Ember.guidFor(this); - options.data.keywords[contextKey] = this; + var contextKey = Ember.$.expando + Ember.guidFor(rootPath); + options.data.keywords[contextKey] = rootPath; // if the path is '' ("this"), just bind directly to the current context var contextPath = path ? contextKey + '.' + path : contextKey;
false
Other
emberjs
ember.js
c6a8f46f3e9337ccfa962f6a86ee3204758210e8.json
add test for `#with view as foo`
packages/ember-handlebars/tests/helpers/with_test.js
@@ -82,6 +82,24 @@ test("it should support #with Foo.bar as qux", function() { equal(view.$().text(), "updated", "should update"); }); +module("Handlebars {{#with keyword as foo}}"); + +test("it should support #with view as foo", function() { + var view = Ember.View.create({ + template: Ember.Handlebars.compile("{{#with view as myView}}{{myView.name}}{{/with}}"), + name: "Sonics" + }); + + appendView(view); + equal(view.$().text(), "Sonics", "should be properly scoped"); + + Ember.run(function() { + Ember.setPath(view, 'name', "Thunder"); + }); + + equal(view.$().text(), "Thunder", "should update"); +}); + if (Ember.VIEW_PRESERVES_CONTEXT) { module("Handlebars {{#with this as foo}}");
false
Other
emberjs
ember.js
8c22290e33814c9e1d509b6fb358263e26023a3e.json
Use reopenClass to add methods to the State class
packages/ember-states/lib/state.js
@@ -161,16 +161,18 @@ Ember.State = Ember.Object.extend(Ember.Evented, var Event = Ember.$ && Ember.$.Event; -Ember.State.transitionTo = function(target) { - var event = function(router, context) { - if (Event && context instanceof Event) { - context = context.context; - } +Ember.State.reopenClass({ + transitionTo: function(target) { + var event = function(router, context) { + if (Event && context instanceof Event) { + context = context.context; + } - router.transitionTo(target, context); - }; + router.transitionTo(target, context); + }; - event.transitionTarget = target; + event.transitionTarget = target; - return event; -}; + return event; + } +});
false
Other
emberjs
ember.js
7019de15f7f5e2183ea12ecbe2337bd7bc6c4f98.json
Remove unused variable and improve argument name
packages/ember-metal/lib/array.js
@@ -71,9 +71,6 @@ var arrayIndexOf = Ember.arrayIndexOf = isNativeFunc(Array.prototype.indexOf) ? return -1; }; - -var slice = [].slice; - Ember.ArrayUtils = { map: function(obj, callback, thisArg) { return obj.map ? obj.map.call(obj, callback, thisArg) : arrayMap.call(obj, callback, thisArg); @@ -87,8 +84,8 @@ Ember.ArrayUtils = { return obj.indexOf ? obj.indexOf.call(obj, element, index) : arrayIndexOf.call(obj, element, index); }, - indexesOf: function(obj, element) { - return element === undefined ? [] : Ember.ArrayUtils.map(element, function(item) { + indexesOf: function(obj, elements) { + return elements === undefined ? [] : Ember.ArrayUtils.map(elements, function(item) { return Ember.ArrayUtils.indexOf(obj, item); }); },
false
Other
emberjs
ember.js
bde32ee1de36c01551c13a5669b16a6e9a98f4b8.json
Improve ArrayUtils by removing unnecessary slices
packages/ember-metal/lib/array.js
@@ -75,23 +75,20 @@ var arrayIndexOf = Ember.arrayIndexOf = isNativeFunc(Array.prototype.indexOf) ? var slice = [].slice; Ember.ArrayUtils = { - map: function(obj) { - var args = slice.call(arguments, 1); - return obj.map ? obj.map.apply(obj, args) : arrayMap.apply(obj, args); + map: function(obj, callback, thisArg) { + return obj.map ? obj.map.call(obj, callback, thisArg) : arrayMap.call(obj, callback, thisArg); }, - forEach: function(obj) { - var args = slice.call(arguments, 1); - return obj.forEach ? obj.forEach.apply(obj, args) : arrayForEach.apply(obj, args); + forEach: function(obj, callback, thisArg) { + return obj.forEach ? obj.forEach.call(obj, callback, thisArg) : arrayForEach.call(obj, callback, thisArg); }, indexOf: function(obj, element, index) { return obj.indexOf ? obj.indexOf.call(obj, element, index) : arrayIndexOf.call(obj, element, index); }, - indexesOf: function(obj) { - var args = slice.call(arguments, 1); - return args[0] === undefined ? [] : Ember.ArrayUtils.map(args[0], function(item) { + indexesOf: function(obj, element) { + return element === undefined ? [] : Ember.ArrayUtils.map(element, function(item) { return Ember.ArrayUtils.indexOf(obj, item); }); },
false
Other
emberjs
ember.js
871042a0d7083c9f5c5b6258fb0a84af814c34dd.json
Use evented system for dom events on views Now we are using real events for all dom events on views. We check if the callback is defined or if listeners are set. If you use callbacks, you can return `false` in order to prevent default In order to achive it goal, this commit adds `has` method to Evented mixin.
packages/ember-handlebars/lib/controls/checkbox.js
@@ -48,9 +48,9 @@ Ember.Checkbox = Ember.View.extend({ checked: false, disabled: false, - change: function() { - Ember.run.once(this, this._updateElementValue); - // returning false will cause IE to not change checkbox state + init: function() { + this._super(); + this.on("change", this, this._updateElementValue); }, /**
true
Other
emberjs
ember.js
871042a0d7083c9f5c5b6258fb0a84af814c34dd.json
Use evented system for dom events on views Now we are using real events for all dom events on views. We check if the callback is defined or if listeners are set. If you use callbacks, you can return `false` in order to prevent default In order to achive it goal, this commit adds `has` method to Evented mixin.
packages/ember-handlebars/lib/controls/select.js
@@ -102,7 +102,7 @@ Ember.Select = Ember.View.extend( */ optionValuePath: 'content', - change: function() { + _change: function() { if (get(this, 'multiple')) { this._changeMultiple(); } else { @@ -146,7 +146,7 @@ Ember.Select = Ember.View.extend( if (selection) { this.selectionDidChange(); } - this.change(); + this._change(); }, _changeSingle: function() { @@ -207,8 +207,8 @@ Ember.Select = Ember.View.extend( init: function() { this._super(); this.on("didInsertElement", this, this._triggerChange); + this.on("change", this, this._change); } - }); Ember.SelectOption = Ember.View.extend({
true
Other
emberjs
ember.js
871042a0d7083c9f5c5b6258fb0a84af814c34dd.json
Use evented system for dom events on views Now we are using real events for all dom events on views. We check if the callback is defined or if listeners are set. If you use callbacks, you can return `false` in order to prevent default In order to achive it goal, this commit adds `has` method to Evented mixin.
packages/ember-handlebars/lib/controls/text_support.js
@@ -23,16 +23,11 @@ Ember.TextSupport = Ember.Mixin.create( insertNewline: Ember.K, cancel: Ember.K, - focusOut: function(event) { - this._elementValueDidChange(); - }, - - change: function(event) { - this._elementValueDidChange(); - }, - - keyUp: function(event) { - this.interpretKeyEvents(event); + init: function() { + this._super(); + this.on("focusOut", this, this._elementValueDidChange); + this.on("change", this, this._elementValueDidChange); + this.on("keyUp", this, this.interpretKeyEvents); }, /**
true
Other
emberjs
ember.js
871042a0d7083c9f5c5b6258fb0a84af814c34dd.json
Use evented system for dom events on views Now we are using real events for all dom events on views. We check if the callback is defined or if listeners are set. If you use callbacks, you can return `false` in order to prevent default In order to achive it goal, this commit adds `has` method to Evented mixin.
packages/ember-handlebars/tests/controls/text_area_test.js
@@ -147,7 +147,7 @@ test("should call the insertNewline method when return key is pressed", function wasCalled = true; }; - textArea.keyUp(event); + textArea.fire('keyUp', event); ok(wasCalled, "invokes insertNewline method"); }); @@ -161,7 +161,7 @@ test("should call the cancel method when escape key is pressed", function() { wasCalled = true; }; - textArea.keyUp(event); + textArea.fire('keyUp', event); ok(wasCalled, "invokes cancel method"); });
true
Other
emberjs
ember.js
871042a0d7083c9f5c5b6258fb0a84af814c34dd.json
Use evented system for dom events on views Now we are using real events for all dom events on views. We check if the callback is defined or if listeners are set. If you use callbacks, you can return `false` in order to prevent default In order to achive it goal, this commit adds `has` method to Evented mixin.
packages/ember-handlebars/tests/controls/text_field_test.js
@@ -143,7 +143,7 @@ test("should call the insertNewline method when return key is pressed", function wasCalled = true; }; - textField.keyUp(event); + textField.fire('keyUp', event); ok(wasCalled, "invokes insertNewline method"); }); @@ -157,7 +157,7 @@ test("should call the cancel method when escape key is pressed", function() { wasCalled = true; }; - textField.keyUp(event); + textField.fire('keyUp', event); ok(wasCalled, "invokes cancel method"); });
true
Other
emberjs
ember.js
871042a0d7083c9f5c5b6258fb0a84af814c34dd.json
Use evented system for dom events on views Now we are using real events for all dom events on views. We check if the callback is defined or if listeners are set. If you use callbacks, you can return `false` in order to prevent default In order to achive it goal, this commit adds `has` method to Evented mixin.
packages/ember-handlebars/tests/handlebars_test.js
@@ -1362,7 +1362,7 @@ test("should not reset cursor position when text field receives keyUp event", fu view.$().setCaretPosition(5); Ember.run(function() { - view.keyUp({}); + view.fire('keyUp', {}); }); equal(view.$().caretPosition(), 5, "The keyUp event should not result in the cursor being reset due to the bindAttr observers");
true
Other
emberjs
ember.js
871042a0d7083c9f5c5b6258fb0a84af814c34dd.json
Use evented system for dom events on views Now we are using real events for all dom events on views. We check if the callback is defined or if listeners are set. If you use callbacks, you can return `false` in order to prevent default In order to achive it goal, this commit adds `has` method to Evented mixin.
packages/ember-runtime/lib/mixins/evented.js
@@ -22,5 +22,9 @@ Ember.Evented = Ember.Mixin.create({ off: function(name, target, method) { Ember.removeListener(this, name, target, method); + }, + + has: function(name) { + return Ember.hasListeners(this, name); } });
true
Other
emberjs
ember.js
871042a0d7083c9f5c5b6258fb0a84af814c34dd.json
Use evented system for dom events on views Now we are using real events for all dom events on views. We check if the callback is defined or if listeners are set. If you use callbacks, you can return `false` in order to prevent default In order to achive it goal, this commit adds `has` method to Evented mixin.
packages/ember-views/lib/views/states/in_dom.js
@@ -43,7 +43,7 @@ Ember.View.states.HasElementState = Ember.State.extend({ // deferred to allow bindings to synchronize. rerender: function(manager) { var view = get(manager, 'view'); - + view._notifyWillRerender(); view.clearRenderedChildren(); @@ -58,15 +58,15 @@ Ember.View.states.HasElementState = Ember.State.extend({ destroyElement: function(manager) { var view = get(manager, 'view'); - + view._notifyWillDestroyElement(); view.domManager.remove(view); return view; }, empty: function(manager) { var view = get(manager, 'view'); - + var _childViews = get(view, '_childViews'), len, idx; if (_childViews) { len = get(_childViews, 'length'); @@ -82,10 +82,9 @@ Ember.View.states.HasElementState = Ember.State.extend({ var view = get(manager, 'view'), eventName = options.eventName, evt = options.event; - - var handler = view[eventName]; - if (Ember.typeOf(handler) === 'function') { - return handler.call(view, evt); + + if (view.has(eventName)) { + return view.fire(eventName, evt); } else { return true; // continue event propagation } @@ -95,7 +94,7 @@ Ember.View.states.HasElementState = Ember.State.extend({ Ember.View.states.InDomState = Ember.State.extend({ insertElement: function(manager, fn) { var view = get(manager, 'view'); - + if (view._lastInsert !== Ember.guidFor(fn)){ return; }
true
Other
emberjs
ember.js
871042a0d7083c9f5c5b6258fb0a84af814c34dd.json
Use evented system for dom events on views Now we are using real events for all dom events on views. We check if the callback is defined or if listeners are set. If you use callbacks, you can return `false` in order to prevent default In order to achive it goal, this commit adds `has` method to Evented mixin.
packages/ember-views/lib/views/view.js
@@ -1859,10 +1859,14 @@ Ember.View = Ember.Object.extend(Ember.Evented, also call methods with the given name. */ fire: function(name) { + this._super.apply(this, arguments); if (this[name]) { - this[name].apply(this, [].slice.call(arguments, 1)); + return this[name].apply(this, [].slice.call(arguments, 1)); } - this._super.apply(this, arguments); + }, + + has: function(name) { + return Ember.typeOf(this[name]) === 'function' || this._super(name); }, // .......................................................
true
Other
emberjs
ember.js
f2a3bd739e9e9ab9ef118599a9a215f766e0882b.json
Remove function names
packages/ember-metal/lib/accessors.js
@@ -26,7 +26,7 @@ var meta = Ember.meta; var get, set; /** @private */ -var basicGet = function get(obj, keyName) { +var basicGet = function(obj, keyName) { var meta = obj[META_KEY], watching = meta && meta.watching[keyName], ret; @@ -59,7 +59,7 @@ if (!Ember.platform.hasPropertyAccessors) { } /** @private */ -var basicSet = function set(obj, keyName, value) { +var basicSet = function(obj, keyName, value) { var isObject = 'object' === typeof obj; var hasProp = isObject && !(keyName in obj); var changed;
false
Other
emberjs
ember.js
eb7a1ac16015c73cf152b61aad825e473aea1c00.json
Fix @each for changes in defineProperty
packages/ember-runtime/lib/system/each_proxy.js
@@ -105,7 +105,7 @@ Ember.EachProxy = Ember.Object.extend({ unknownProperty: function(keyName, value) { var ret; ret = new EachArray(this._content, keyName, this); - new Ember.Descriptor().setup(this, keyName, ret); + Ember.defineProperty(this, keyName, null, ret); this.beginObservingContentKey(keyName); return ret; },
false
Other
emberjs
ember.js
64ef59005be9902815005846e641a5253ff58c59.json
Fix required descriptor
packages/ember-metal/lib/mixin.js
@@ -117,6 +117,7 @@ function mergeMixins(mixins, m, descs, values, base) { value = baseValue ? baseValue.concat(value) : Ember.makeArray(value); } + descs[key] = undefined; values[key] = value; } }
false
Other
emberjs
ember.js
7ed1ed7dd1f2bb00a350cb78e3d590167816cee7.json
Use a fresh meta to get the current value
packages/ember-metal/lib/watching.js
@@ -437,7 +437,7 @@ var switchToWatched = function(obj, keyName, meta) { enumerable: true, set: mandatorySetter, get: function(key) { - return meta.values[keyName]; + return metaFor(this).values[keyName]; } };
false
Other
emberjs
ember.js
149fe898645e45e499b2b1acf31095b9c859599a.json
Fix one last alias case
packages/ember-metal/lib/mixin.js
@@ -226,7 +226,7 @@ function applyMixin(obj, mixins, partial) { } else { while (desc && desc instanceof Alias) { var altKey = desc.methodName; - if (descs[altKey]) { + if (descs[altKey] || values[altKey]) { value = values[altKey]; desc = descs[altKey]; } else if (m.descs[altKey]) {
false
Other
emberjs
ember.js
76c313fc998b70328204d720a05892df81e4a423.json
Make a null desc work for defineProperty
packages/ember-metal/lib/properties.js
@@ -125,7 +125,7 @@ Ember.defineProperty = function(obj, keyName, desc, val) { } else { if (descs[keyName]) { metaFor(obj).descs[keyName] = null; } - if (desc === undefined) { + if (desc == null) { if (existingDesc) { objectDefineProperty(obj, keyName, { enumerable: true,
false
Other
emberjs
ember.js
49bd20f915892c3e6d002a4794eaacba7112b7e9.json
Remove references to SIMPLE_PROPERTY
packages/ember-metal/lib/mixin.js
@@ -103,7 +103,7 @@ function mergeMixins(mixins, m, descs, values, base) { } else { // impl super if needed... if (isMethod(value)) { - ovalue = descs[key] === Ember.SIMPLE_PROPERTY && values[key]; + ovalue = descs[key] === undefined && values[key]; if (!ovalue) { ovalue = base[key]; } if ('function' !== typeof ovalue) { ovalue = null; } if (ovalue) {
true
Other
emberjs
ember.js
49bd20f915892c3e6d002a4794eaacba7112b7e9.json
Remove references to SIMPLE_PROPERTY
packages/ember-metal/lib/properties.js
@@ -88,7 +88,7 @@ var extractValue = function(obj, keyName, watching) { }); // define a simple property - Ember.defineProperty(contact, 'lastName', Ember.SIMPLE_PROPERTY, 'Jolley'); + Ember.defineProperty(contact, 'lastName', undefined, 'Jolley'); // define a computed property Ember.defineProperty(contact, 'fullName', Ember.computed(function() {
true
Other
emberjs
ember.js
49bd20f915892c3e6d002a4794eaacba7112b7e9.json
Remove references to SIMPLE_PROPERTY
packages/ember-metal/lib/watching.js
@@ -17,7 +17,6 @@ var guidFor = Ember.guidFor, get = Ember.get, set = Ember.set, normalizeTuple = Ember.normalizeTuple.primitive, - SIMPLE_PROPERTY = Ember.SIMPLE_PROPERTY, GUID_KEY = Ember.GUID_KEY, META_KEY = Ember.META_KEY, notifyObservers = Ember.notifyObservers,
true
Other
emberjs
ember.js
49bd20f915892c3e6d002a4794eaacba7112b7e9.json
Remove references to SIMPLE_PROPERTY
packages/ember-metal/tests/binding/connect_test.js
@@ -69,7 +69,7 @@ testBoth('Connecting a binding between two objects through property defined afte performTest(binding, a, b, get, set, function () { binding.connect(a); - Ember.defineProperty(a, 'b', Ember.SIMPLE_PROPERTY, b); + Ember.defineProperty(a, 'b', undefined, b); }); });
true
Other
emberjs
ember.js
49bd20f915892c3e6d002a4794eaacba7112b7e9.json
Remove references to SIMPLE_PROPERTY
packages/ember-metal/tests/properties_test.js
@@ -9,6 +9,6 @@ module('Ember.defineProperty'); test('toString', function() { var obj = {}; - Ember.defineProperty(obj, 'toString', Ember.SIMPLE_PROPERTY, function() { return 'FOO'; }); + Ember.defineProperty(obj, 'toString', undefined, function() { return 'FOO'; }); equal(obj.toString(), 'FOO', 'should replace toString'); });
true
Other
emberjs
ember.js
49bd20f915892c3e6d002a4794eaacba7112b7e9.json
Remove references to SIMPLE_PROPERTY
packages/ember-metal/tests/watching/watch_test.js
@@ -95,7 +95,7 @@ test("watching a chain then defining the property", function () { var foo = {bar: 'bar'}; Ember.watch(obj, 'foo.bar'); - Ember.defineProperty(obj, 'foo', Ember.SIMPLE_PROPERTY, foo); + Ember.defineProperty(obj, 'foo', undefined, foo); Ember.set(foo, 'bar', 'baz'); deepEqual(willKeys, ['bar', 'foo.bar'], 'should have invoked willChange with bar, foo.bar'); @@ -110,7 +110,7 @@ test("watching a chain then defining the nested property", function () { var baz = {baz: 'baz'}; Ember.watch(obj, 'foo.bar.baz'); - Ember.defineProperty(bar, 'bar', Ember.SIMPLE_PROPERTY, baz); + Ember.defineProperty(bar, 'bar', undefined, baz); Ember.set(baz, 'baz', 'BOO'); deepEqual(willKeys, ['baz', 'foo.bar.baz'], 'should have invoked willChange with bar, foo.bar');
true
Other
emberjs
ember.js
664c34812b4f31b84dc67e186741b60813f6926e.json
Fix action tests for IE
packages/ember-application/tests/system/action_url_test.js
@@ -58,7 +58,7 @@ test("it does not generate the URL when href property is not specified", functio ok(!view.$().html().match(/href=['"]\/foo\/bar['"]/), "The html (" + view.$().html() + ") has the href /foo/bar in it"); }); -test("it sets a URL with a context", function() { +test("it sets an URL with a context", function() { var router = Ember.Router.create({ location: { formatURL: function(url) { @@ -93,7 +93,7 @@ test("it sets a URL with a context", function() { equal(router.getPath('currentState.path'), "root.index", "precond - the current stat is root.index"); var view = Ember.View.create({ - template: compile('<a {{action showDashboard context="controller.component" href=true}}>') + template: compile('<a {{action showDashboard context="controller.component" href=true}}>test</a>') }); var controller = {
false
Other
emberjs
ember.js
6155d7898eed50cc7bc88fe9b6d06d73c5981411.json
Fix unsupported method errors in older browsers
packages/ember-application/lib/system/hash_location.js
@@ -52,7 +52,11 @@ Ember.HashLocation = Ember.Object.extend({ }; get(this, 'callbacks').pushObject(hashchange); - window.addEventListener('hashchange', hashchange); + + // This won't work on old browsers anyway, but this check prevents errors + if (window.addEventListener) { + window.addEventListener('hashchange', hashchange); + } }, /**
true
Other
emberjs
ember.js
6155d7898eed50cc7bc88fe9b6d06d73c5981411.json
Fix unsupported method errors in older browsers
packages/ember-application/lib/system/history_location.js
@@ -49,7 +49,11 @@ Ember.HistoryLocation = Ember.Object.extend({ }; get(this, 'callbacks').pushObject(popstate); - window.addEventListener('popstate', popstate); + + // This won't work on old browsers anyway, but this check prevents errors + if (window.addEventListener) { + window.addEventListener('popstate', popstate); + } }, /**
true