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
7ba9475a3a364a4083928ca4ac29859c73130cf5.json
Remove trailing whitespace
packages/ember-old-router/lib/application/system/application.js
@@ -254,7 +254,7 @@ Ember.Application = Ember.Namespace.extend( /** Should the application initialize itself after it's created. You can - set this to `false` if you'd like to choose when to initialize your + set this to `false` if you'd like to choose when to initialize your application. This defaults to `!Ember.testing` @property autoinit
true
Other
emberjs
ember.js
7ba9475a3a364a4083928ca4ac29859c73130cf5.json
Remove trailing whitespace
packages/ember-old-router/lib/router.js
@@ -219,7 +219,7 @@ var merge = function(original, hash) { first argument and a hash of the URL's dynamic segments and values as its second argument. - The following route structure when loaded with the URL + The following route structure when loaded with the URL "#/fixed/thefirstvalue/anotherFixed/thesecondvalue": ```javascript @@ -287,8 +287,8 @@ var merge = function(original, hash) { App.initialize(); ``` - Transitioning to `root.bRoute` with a context of - `Object.create({name: 'Yehuda'})` will call the `Route`'s `serialize` + Transitioning to `root.bRoute` with a context of + `Object.create({name: 'Yehuda'})` will call the `Route`'s `serialize` method with the context as its second argument and update the URL to '#/staticSection/Yehuda'.
true
Other
emberjs
ember.js
7ba9475a3a364a4083928ca4ac29859c73130cf5.json
Remove trailing whitespace
packages/ember-runtime/lib/mixins/array.js
@@ -313,9 +313,9 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot @method arrayContentWillChange @param {Number} startIdx The starting index in the array that will change. - @param {Number} removeAmt The number of items that will be removed. If you + @param {Number} removeAmt The number of items that will be removed. If you pass `null` assumes 0 - @param {Number} addAmt The number of items that will be added If you + @param {Number} addAmt The number of items that will be added If you pass `null` assumes 0. @return {Ember.Array} receiver */
true
Other
emberjs
ember.js
7ba9475a3a364a4083928ca4ac29859c73130cf5.json
Remove trailing whitespace
packages/ember-runtime/lib/mixins/enumerable.js
@@ -103,7 +103,7 @@ Ember.Enumerable = Ember.Mixin.create({ @method nextObject @param {Number} index the current index of the iteration - @param {Object} previousObject the value returned by the last call to + @param {Object} previousObject the value returned by the last call to `nextObject`. @param {Object} context a context object you can use to maintain state. @return {Object} the next object in the iteration or undefined
true
Other
emberjs
ember.js
7ba9475a3a364a4083928ca4ac29859c73130cf5.json
Remove trailing whitespace
packages/ember-runtime/lib/mixins/mutable_array.js
@@ -45,11 +45,11 @@ Ember.MutableArray = Ember.Mixin.create(Ember.Array, Ember.MutableEnumerable, passed array. You should also call `this.enumerableContentDidChange()` @method replace - @param {Number} idx Starting index in the array to replace. If + @param {Number} idx Starting index in the array to replace. If idx >= length, then append to the end of the array. - @param {Number} amt Number of elements that should be removed from + @param {Number} amt Number of elements that should be removed from the array, starting at *idx*. - @param {Array} objects An array of zero or more objects that should be + @param {Array} objects An array of zero or more objects that should be inserted into the array at *idx* */ replace: Ember.required(),
true
Other
emberjs
ember.js
7ba9475a3a364a4083928ca4ac29859c73130cf5.json
Remove trailing whitespace
packages/ember-runtime/lib/system/core_object.js
@@ -236,14 +236,14 @@ CoreObject.PrototypeMixin = Mixin.create({ view.get('classNames'); // ['ember-view', 'bar', 'foo', 'baz'] ``` Adding a single property that is not an array will just add it in the array: - + ```javascript var view = App.FooBarView.create({ classNames: 'baz' }) view.get('classNames'); // ['ember-view', 'bar', 'foo', 'baz'] ``` - + Using the `concatenatedProperties` property, we can tell to Ember that mix the content of the properties.
true
Other
emberjs
ember.js
7ba9475a3a364a4083928ca4ac29859c73130cf5.json
Remove trailing whitespace
packages/ember-runtime/tests/suites/enumerable/reject.js
@@ -25,7 +25,7 @@ suite.test('should be the inverse of filter', function() { rejected = obj.reject(isEven); deepEqual(filtered, [2,4], 'filtered evens'); - deepEqual(rejected, [1,3], 'rejected evens'); + deepEqual(rejected, [1,3], 'rejected evens'); }); // ..........................................................
true
Other
emberjs
ember.js
7ba9475a3a364a4083928ca4ac29859c73130cf5.json
Remove trailing whitespace
packages/ember-views/lib/views/collection_view.js
@@ -37,7 +37,7 @@ var get = Ember.get, set = Ember.set, fmt = Ember.String.fmt; Given an empty `<body>` and the following code: - ```javascript + ```javascript someItemsView = Ember.CollectionView.create({ classNames: ['a-collection'], content: ['A','B','C'],
true
Other
emberjs
ember.js
7ba9475a3a364a4083928ca4ac29859c73130cf5.json
Remove trailing whitespace
packages/ember-views/lib/views/view.js
@@ -731,15 +731,15 @@ class: * `mouseEnter` * `mouseLeave` - Form events: + Form events: * `submit` * `change` * `focusIn` * `focusOut` * `input` - HTML5 drag and drop events: + HTML5 drag and drop events: * `dragStart` * `drag` @@ -1478,7 +1478,7 @@ Ember.View = Ember.CoreView.extend( Appends the view's element to the document body. If the view does not have an HTML representation yet, `createElement()` will be called automatically. - + If your application uses the `rootElement` property, you must append the view within that element. Rendering views outside of the `rootElement` is not supported. @@ -2297,14 +2297,14 @@ Ember.View.reopenClass({ `className` and optional `falsyClassName`. - if a `className` or `falsyClassName` has been specified: - - if the value is truthy and `className` has been specified, + - if the value is truthy and `className` has been specified, `className` is returned - - if the value is falsy and `falsyClassName` has been specified, + - if the value is falsy and `falsyClassName` has been specified, `falsyClassName` is returned - otherwise `null` is returned - - if the value is `true`, the dasherized last part of the supplied path + - if the value is `true`, the dasherized last part of the supplied path is returned - - if the value is not `false`, `undefined` or `null`, the `value` + - if the value is not `false`, `undefined` or `null`, the `value` is returned - if none of the above rules apply, `null` is returned
true
Other
emberjs
ember.js
2c57dcf26baade027b78a08309b50db97a2feb14.json
Remove tab indentation
packages/rsvp/lib/main.js
@@ -245,35 +245,35 @@ define("rsvp", } function all(promises) { - var i, results = []; - var allPromise = new Promise(); - var remaining = promises.length; + var i, results = []; + var allPromise = new Promise(); + var remaining = promises.length; if (remaining === 0) { allPromise.resolve([]); } - var resolver = function(index) { - return function(value) { - resolve(index, value); - }; - }; - - var resolve = function(index, value) { - results[index] = value; - if (--remaining === 0) { - allPromise.resolve(results); - } - }; - - var reject = function(error) { - allPromise.reject(error); - }; - - for (i = 0; i < remaining; i++) { - promises[i].then(resolver(i), reject); - } - return allPromise; + var resolver = function(index) { + return function(value) { + resolve(index, value); + }; + }; + + var resolve = function(index, value) { + results[index] = value; + if (--remaining === 0) { + allPromise.resolve(results); + } + }; + + var reject = function(error) { + allPromise.reject(error); + }; + + for (i = 0; i < remaining; i++) { + promises[i].then(resolver(i), reject); + } + return allPromise; } EventTarget.mixin(Promise.prototype);
false
Other
emberjs
ember.js
531db2ef0b3b62315ba322fa69d0257ff34c9193.json
Improve Ember.Array slice implementation Add support for negative index arguments.
packages/ember-runtime/lib/mixins/array.js
@@ -160,6 +160,10 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot var length = get(this, 'length') ; if (none(beginIndex)) beginIndex = 0 ; if (none(endIndex) || (endIndex > length)) endIndex = length ; + + if (beginIndex < 0) beginIndex = length + beginIndex; + if (endIndex < 0) endIndex = length + endIndex; + while(beginIndex < endIndex) { ret[ret.length] = this.objectAt(beginIndex++) ; }
true
Other
emberjs
ember.js
531db2ef0b3b62315ba322fa69d0257ff34c9193.json
Improve Ember.Array slice implementation Add support for negative index arguments.
packages/ember-runtime/tests/mixins/array_test.js
@@ -37,12 +37,7 @@ var TestArray = Ember.Object.extend(Ember.Array, { length: Ember.computed(function() { return this._content.length; - }), - - slice: function() { - return this._content.slice(); - } - + }) }); @@ -74,6 +69,24 @@ test("the return value of slice has Ember.Array applied", function(){ equal(Ember.Array.detect(y), true, "mixin should be applied"); }); +test("slice supports negative index arguments", function(){ + var testArray = new TestArray([1,2,3,4]); + + deepEqual(testArray.slice(-2), [3, 4], 'slice(-2)'); + deepEqual(testArray.slice(-2, -1), [3], 'slice(-2, -1'); + deepEqual(testArray.slice(-2, -2), [], 'slice(-2, -2)'); + deepEqual(testArray.slice(-1, -2), [], 'slice(-1, -2)'); + + deepEqual(testArray.slice(-4, 1), [1], 'slice(-4, 1)'); + deepEqual(testArray.slice(-4, 5), [1,2,3,4], 'slice(-4, 5)'); + deepEqual(testArray.slice(-4), [1,2,3,4], 'slice(-4)'); + + deepEqual(testArray.slice(0, -1), [1,2,3], 'slice(0, -1)'); + deepEqual(testArray.slice(0, -4), [], 'slice(0, -4)'); + deepEqual(testArray.slice(0, -3), [1], 'slice(0, -3)'); + +}); + // .......................................................... // CONTENT DID CHANGE //
true
Other
emberjs
ember.js
ffa4493782813ed92d06ea5ce0bed3c14df5ec5e.json
Fix ArrayProxy arrangedObject handling - Fixes #2120, #2138
packages/ember-runtime/lib/system/array_proxy.js
@@ -6,6 +6,8 @@ require('ember-runtime/system/object'); @submodule ember-runtime */ +var OUT_OF_RANGE_EXCEPTION = "Index out of range"; +var EMPTY = []; var get = Ember.get, set = Ember.set; @@ -211,12 +213,100 @@ Ember.ArrayProxy = Ember.Object.extend(Ember.MutableArray, // No dependencies since Enumerable notifies length of change }), - replace: function(idx, amt, objects) { - Ember.assert('The content property of '+ this.constructor + ' should be set before modifying it', this.get('content')); - if (get(this, 'content')) this.replaceContent(idx, amt, objects); + _replace: function(idx, amt, objects) { + var content = get(this, 'content'); + Ember.assert('The content property of '+ this.constructor + ' should be set before modifying it', content); + if (content) this.replaceContent(idx, amt, objects); + return this; + }, + + replace: function() { + if (get(this, 'arrangedContent') === get(this, 'content')) { + this._replace.apply(this, arguments); + } else { + throw new Ember.Error("Using replace on an arranged ArrayProxy is not allowed."); + } + }, + + _insertAt: function(idx, object) { + var content = this.get('content'); + if (idx > get(this, 'content.length')) throw new Error(OUT_OF_RANGE_EXCEPTION); + this._replace(idx, 0, [object]); + return this; + }, + + insertAt: function(idx, object) { + if (get(this, 'arrangedContent') === get(this, 'content')) { + return this._insertAt(idx, object); + } else { + throw new Ember.Error("Using insertAt on an arranged ArrayProxy is not allowed."); + } + }, + + removeAt: function(start, len) { + if ('number' === typeof start) { + var content = get(this, 'content'), + arrangedContent = get(this, 'arrangedContent'), + indices = [], i; + + if ((start < 0) || (start >= get(this, 'length'))) { + throw new Error(OUT_OF_RANGE_EXCEPTION); + } + + if (len === undefined) len = 1; + + // Get a list of indices in original content to remove + for (i=start; i<start+len; i++) { + // Use arrangedContent here so we avoid confusion with objects transformed by objectAtContent + indices.push(content.indexOf(arrangedContent.objectAt(i))); + } + + // Replace in reverse order since indices will change + indices.sort(function(a,b) { return b - a; }); + + Ember.beginPropertyChanges(); + for (i=0; i<indices.length; i++) { + this._replace(indices[i], 1, EMPTY); + } + Ember.endPropertyChanges(); + } + + return this ; + }, + + pushObject: function(obj) { + this._insertAt(get(this, 'content.length'), obj) ; + return obj ; + }, + + pushObjects: function(objects) { + this._replace(get(this, 'length'), 0, objects); return this; }, + setObjects: function(objects) { + if (objects.length === 0) return this.clear(); + + var len = get(this, 'length'); + this._replace(0, len, objects); + return this; + }, + + unshiftObject: function(obj) { + this._insertAt(0, obj) ; + return obj ; + }, + + unshiftObjects: function(objects) { + this._replace(0, 0, objects); + return this; + }, + + slice: function() { + var arr = this.toArray(); + return arr.slice.apply(arr, arguments); + }, + arrangedContentArrayWillChange: function(item, idx, removedCnt, addedCnt) { this.arrayContentWillChange(idx, removedCnt, addedCnt); },
true
Other
emberjs
ember.js
ffa4493782813ed92d06ea5ce0bed3c14df5ec5e.json
Fix ArrayProxy arrangedObject handling - Fixes #2120, #2138
packages/ember-runtime/tests/system/array_proxy/arranged_content_test.js
@@ -0,0 +1,297 @@ +var array; + +module("Ember.ArrayProxy - arrangedContent", { + setup: function() { + Ember.run(function() { + array = Ember.ArrayProxy.createWithMixins({ + content: Ember.A([1,2,4,5]), + arrangedContent: Ember.computed(function() { + var content = this.get('content'); + return content && Ember.A(content.slice().sort(function(a,b) { + if (a == null) { a = -1; } + if (b == null) { b = -1; } + return b - a; + })); + }).property('content.[]') + }); + }); + }, + teardown: function() { + Ember.run(function() { + array.destroy(); + }); + } +}); + +test("addObject - adds to end of 'content' if not present", function() { + Ember.run(function() { array.addObject(3); }); + deepEqual(array.get('content'), [1,2,4,5,3], 'adds to end of content'); + deepEqual(array.get('arrangedContent'), [5,4,3,2,1], 'arrangedContent stays sorted'); + + Ember.run(function() { array.addObject(1); }); + deepEqual(array.get('content'), [1,2,4,5,3], 'does not add existing number to content'); +}); + +test("addObjects - adds to end of 'content' if not present", function() { + Ember.run(function() { array.addObjects([1,3,6]); }); + deepEqual(array.get('content'), [1,2,4,5,3,6], 'adds to end of content'); + deepEqual(array.get('arrangedContent'), [6,5,4,3,2,1], 'arrangedContent stays sorted'); +}); + +test("compact - returns arrangedContent without nulls", function() { + Ember.run(function() { array.set('content', Ember.A([1,3,null,2])); }); + deepEqual(array.compact(), [3,2,1]); +}); + +test("indexOf - returns index of object in arrangedContent", function() { + equal(array.indexOf(4), 1, 'returns arranged index'); +}); + +test("insertAt - raises, indeterminate behavior", function() { + raises(function() { + Ember.run(function() { array.insertAt(2,3); }); + }); +}); + +test("lastIndexOf - returns last index of object in arrangedContent", function() { + Ember.run(function() { array.pushObject(4); }); + equal(array.lastIndexOf(4), 2, 'returns last arranged index'); +}); + +test("nextObject - returns object at index in arrangedContent", function() { + equal(array.nextObject(1), 4, 'returns object at index'); +}); + +test("objectAt - returns object at index in arrangedContent", function() { + equal(array.objectAt(1), 4, 'returns object at index'); +}); + +// Not sure if we need a specific test for it, since it's internal +test("objectAtContent - returns object at index in arrangedContent", function() { + equal(array.objectAtContent(1), 4, 'returns object at index'); +}); + +test("objectsAt - returns objects at indices in arrangedContent", function() { + deepEqual(array.objectsAt([0,2,4]), [5,2,undefined], 'returns objects at indices'); +}); + +test("popObject - removes last object in arrangedContent", function() { + var popped; + Ember.run(function() { popped = array.popObject(); }); + equal(popped, 1, 'returns last object'); + deepEqual(array.get('content'), [2,4,5], 'removes from content'); +}); + +test("pushObject - adds to end of content even if it already exists", function() { + Ember.run(function() { array.pushObject(1); }); + deepEqual(array.get('content'), [1,2,4,5,1], 'adds to end of content'); +}); + +test("pushObjects - adds multiple to end of content even if it already exists", function() { + Ember.run(function() { array.pushObjects([1,2,4]); }); + deepEqual(array.get('content'), [1,2,4,5,1,2,4], 'adds to end of content'); +}); + +test("removeAt - removes from index in arrangedContent", function() { + Ember.run(function() { array.removeAt(1,2); }); + deepEqual(array.get('content'), [1,5]); +}); + +test("removeObject - removes object from content", function() { + Ember.run(function() { array.removeObject(2); }); + deepEqual(array.get('content'), [1,4,5]); +}); + +test("removeObjects - removes objects from content", function() { + Ember.run(function() { array.removeObjects([2,4,6]); }); + deepEqual(array.get('content'), [1,5]); +}); + +test("replace - raises, indeterminate behavior", function() { + raises(function() { + Ember.run(function() { array.replace(1, 2, [3]); }); + }); +}); + +test("replaceContent - does a standard array replace on content", function() { + Ember.run(function() { array.replaceContent(1, 2, [3]); }); + deepEqual(array.get('content'), [1,3,5]); +}); + +test("reverseObjects - raises, use Sortable#sortAscending", function() { + raises(function() { + Ember.run(function() { array.reverseObjects(); }); + }); +}); + +test("setObjects - replaces entire content", function() { + Ember.run(function() { array.setObjects([6,7,8]); }); + deepEqual(array.get('content'), [6,7,8], 'replaces content'); +}); + +test("shiftObject - removes from start of arrangedContent", function() { + var shifted; + Ember.run(function() { shifted = array.shiftObject(); }); + equal(shifted, 5, 'returns first object'); + deepEqual(array.get('content'), [1,2,4], 'removes object from content'); +}); + +test("slice - returns a slice of the arrangedContent", function() { + deepEqual(array.slice(1,3), [4,2], 'returns sliced arrangedContent'); +}); + +test("toArray - returns copy of arrangedContent", function() { + deepEqual(array.toArray(), [5,4,2,1]); +}); + +test("unshiftObject - adds to start of content", function() { + Ember.run(function(){ array.unshiftObject(6); }); + deepEqual(array.get('content'), [6,1,2,4,5], 'adds to start of content'); +}); + +test("unshiftObjects - adds to start of content", function() { + Ember.run(function(){ array.unshiftObjects([6,7]); }); + deepEqual(array.get('content'), [6,7,1,2,4,5], 'adds to start of content'); +}); + +test("without - returns arrangedContent without object", function() { + deepEqual(array.without(2), [5,4,1], 'returns arranged without object'); +}); + +test("lastObject - returns last arranged object", function() { + equal(array.get('lastObject'), 1, 'returns last arranged object'); +}); + +test("firstObject - returns first arranged object", function() { + equal(array.get('firstObject'), 5, 'returns first arranged object'); +}); + + +module("Ember.ArrayProxy - arrangedContent matching content", { + setup: function() { + Ember.run(function() { + array = Ember.ArrayProxy.createWithMixins({ + content: Ember.A([1,2,4,5]) + }); + }); + }, + teardown: function() { + Ember.run(function() { + array.destroy(); + }); + } +}); + +test("insertAt - inserts object at specified index", function() { + Ember.run(function() { array.insertAt(2, 3); }); + deepEqual(array.get('content'), [1,2,3,4,5]); +}); + +test("replace - does a standard array replace", function() { + Ember.run(function() { array.replace(1, 2, [3]); }); + deepEqual(array.get('content'), [1,3,5]); +}); + +test("reverseObjects - reverses content", function() { + Ember.run(function() { array.reverseObjects(); }); + deepEqual(array.get('content'), [5,4,2,1]); +}); + +module("Ember.ArrayProxy - arrangedContent with transforms", { + setup: function() { + Ember.run(function() { + array = Ember.ArrayProxy.createWithMixins({ + content: Ember.A([1,2,4,5]), + + arrangedContent: Ember.computed(function() { + var content = this.get('content'); + return content && Ember.A(content.slice().sort(function(a,b) { + if (a == null) { a = -1; } + if (b == null) { b = -1; } + return b - a; + })); + }).property('content.[]'), + + objectAtContent: function(idx) { + var obj = this.get('arrangedContent').objectAt(idx); + return obj && obj.toString(); + } + }); + }); + }, + teardown: function() { + Ember.run(function() { + array.destroy(); + }); + } +}); + +test("indexOf - returns index of object in arrangedContent", function() { + equal(array.indexOf('4'), 1, 'returns arranged index'); +}); + +test("lastIndexOf - returns last index of object in arrangedContent", function() { + Ember.run(function() { array.pushObject(4); }); + equal(array.lastIndexOf('4'), 2, 'returns last arranged index'); +}); + +test("nextObject - returns object at index in arrangedContent", function() { + equal(array.nextObject(1), '4', 'returns object at index'); +}); + +test("objectAt - returns object at index in arrangedContent", function() { + equal(array.objectAt(1), '4', 'returns object at index'); +}); + +// Not sure if we need a specific test for it, since it's internal +test("objectAtContent - returns object at index in arrangedContent", function() { + equal(array.objectAtContent(1), '4', 'returns object at index'); +}); + +test("objectsAt - returns objects at indices in arrangedContent", function() { + deepEqual(array.objectsAt([0,2,4]), ['5','2',undefined], 'returns objects at indices'); +}); + +test("popObject - removes last object in arrangedContent", function() { + var popped; + Ember.run(function() { popped = array.popObject(); }); + equal(popped, '1', 'returns last object'); + deepEqual(array.get('content'), [2,4,5], 'removes from content'); +}); + +test("removeObject - removes object from content", function() { + Ember.run(function() { array.removeObject('2'); }); + deepEqual(array.get('content'), [1,4,5]); +}); + +test("removeObjects - removes objects from content", function() { + Ember.run(function() { array.removeObjects(['2','4','6']); }); + deepEqual(array.get('content'), [1,5]); +}); + +test("shiftObject - removes from start of arrangedContent", function() { + var shifted; + Ember.run(function() { shifted = array.shiftObject(); }); + equal(shifted, '5', 'returns first object'); + deepEqual(array.get('content'), [1,2,4], 'removes object from content'); +}); + +test("slice - returns a slice of the arrangedContent", function() { + deepEqual(array.slice(1,3), ['4','2'], 'returns sliced arrangedContent'); +}); + +test("toArray - returns copy of arrangedContent", function() { + deepEqual(array.toArray(), ['5','4','2','1']); +}); + +test("without - returns arrangedContent without object", function() { + deepEqual(array.without('2'), ['5','4','1'], 'returns arranged without object'); +}); + +test("lastObject - returns last arranged object", function() { + equal(array.get('lastObject'), '1', 'returns last arranged object'); +}); + +test("firstObject - returns first arranged object", function() { + equal(array.get('firstObject'), '5', 'returns first arranged object'); +}); \ No newline at end of file
true
Other
emberjs
ember.js
7357a1f1d1513cda1326ff60a4d0dc629907d154.json
Fix failing test This package couldn't be required from test.
packages/ember-runtime/tests/core/is_empty_test.js
@@ -1,4 +1,3 @@ -require('ember-metal/core'); module("Ember.isEmpty"); test("Ember.isEmpty", function() {
false
Other
emberjs
ember.js
d232a68ead674ce5a507a5ab6e86d8499a5ba3c1.json
extract Ember.isEmpty into ember-metal Ember computed.empty should always have identical semantics
packages/ember-metal/lib/computed.js
@@ -437,7 +437,7 @@ Ember.computed.not = function(dependentKey) { Ember.computed.empty = function(dependentKey) { return Ember.computed(dependentKey, function(key) { var val = get(this, dependentKey); - return val === undefined || val === null || val === '' || (Ember.isArray(val) && get(val, 'length') === 0); + return Ember.isEmpty(val); }); };
true
Other
emberjs
ember.js
d232a68ead674ce5a507a5ab6e86d8499a5ba3c1.json
extract Ember.isEmpty into ember-metal Ember computed.empty should always have identical semantics
packages/ember-metal/lib/core.js
@@ -228,3 +228,30 @@ Ember.merge = function(original, updates) { original[prop] = updates[prop]; } }; +/** + Verifies that a value is `null` or an empty string, empty array, + or empty function. + + Constrains the rules on `Ember.isNone` by returning false for empty + string and empty arrays. + + ```javascript + Ember.isEmpty(); // true + Ember.isEmpty(null); // true + Ember.isEmpty(undefined); // true + Ember.isEmpty(''); // true + Ember.isEmpty([]); // true + Ember.isEmpty('Adam Hawkins'); // false + Ember.isEmpty([0,1,2]); // false + ``` + + @method isEmpty + @for Ember + @param {Object} obj Value to test + @return {Boolean} +*/ +Ember.isEmpty = function(obj) { + return obj === null || obj === undefined || (obj.length === 0 && typeof obj !== 'function') || (typeof obj === 'object' && Ember.get(obj, 'length') === 0); +}; +Ember.empty = Ember.deprecateFunc("Ember.empty is deprecated. Please use Ember.isEmpty instead.", Ember.isEmpty) ; +
true
Other
emberjs
ember.js
d232a68ead674ce5a507a5ab6e86d8499a5ba3c1.json
extract Ember.isEmpty into ember-metal Ember computed.empty should always have identical semantics
packages/ember-metal/tests/core/is_empty_test.js
@@ -2,8 +2,7 @@ module("Ember.isEmpty"); test("Ember.isEmpty", function() { var string = "string", fn = function() {}, - object = {length: 0}, - arrayProxy = Ember.ArrayProxy.create({ content: Ember.A([]) }); + object = {length: 0}; equal(true, Ember.isEmpty(null), "for null"); equal(true, Ember.isEmpty(undefined), "for undefined"); @@ -16,5 +15,4 @@ test("Ember.isEmpty", function() { equal(true, Ember.isEmpty([]), "for an empty Array"); equal(false, Ember.isEmpty({}), "for an empty Object"); equal(true, Ember.isEmpty(object), "for an Object that has zero 'length'"); - equal(true, Ember.isEmpty(arrayProxy), "for an ArrayProxy that has empty content"); });
true
Other
emberjs
ember.js
d232a68ead674ce5a507a5ab6e86d8499a5ba3c1.json
extract Ember.isEmpty into ember-metal Ember computed.empty should always have identical semantics
packages/ember-runtime/lib/core.js
@@ -106,34 +106,6 @@ Ember.isNone = function(obj) { }; Ember.none = Ember.deprecateFunc("Ember.none is deprecated. Please use Ember.isNone instead.", Ember.isNone); -/** - Verifies that a value is `null` or an empty string, empty array, - or empty function. - - Constrains the rules on `Ember.isNone` by returning false for empty - string and empty arrays. - - ```javascript - Ember.isEmpty(); // true - Ember.isEmpty(null); // true - Ember.isEmpty(undefined); // true - Ember.isEmpty(''); // true - Ember.isEmpty([]); // true - Ember.isEmpty('Adam Hawkins'); // false - Ember.isEmpty([0,1,2]); // false - ``` - - @method isEmpty - @for Ember - @param {Object} obj Value to test - @return {Boolean} -*/ -Ember.isEmpty = function(obj) { - return obj === null || obj === undefined || (obj.length === 0 && typeof obj !== 'function') || (typeof obj === 'object' && Ember.get(obj, 'length') === 0); -}; -Ember.empty = Ember.deprecateFunc("Ember.empty is deprecated. Please use Ember.isEmpty instead.", Ember.isEmpty) ; - -/** This will compare two javascript values of possibly different types. It will tell you which one is greater than the other by returning:
true
Other
emberjs
ember.js
d232a68ead674ce5a507a5ab6e86d8499a5ba3c1.json
extract Ember.isEmpty into ember-metal Ember computed.empty should always have identical semantics
packages/ember-runtime/tests/core/is_empty_test.js
@@ -0,0 +1,8 @@ +require('ember-metal/core'); +module("Ember.isEmpty"); + +test("Ember.isEmpty", function() { + var arrayProxy = Ember.ArrayProxy.create({ content: Ember.A([]) }); + + equal(true, Ember.isEmpty(arrayProxy), "for an ArrayProxy that has empty content"); +});
true
Other
emberjs
ember.js
4f340e6c73032af032d068ebd5bf7cce95d96732.json
Remove unnecessary '#' '#' is unnecessary for putting return value.
packages/ember-runtime/lib/system/core_object.js
@@ -342,7 +342,7 @@ CoreObject.PrototypeMixin = Mixin.create({ } }); teacher = App.Teacher.create() - teacher.toString(); // #=> "<App.Teacher:ember1026:Tom Dale>" + teacher.toString(); //=> "<App.Teacher:ember1026:Tom Dale>" @method toString @return {String} string representation
false
Other
emberjs
ember.js
0c77f3643bb9877b427d260a76f649bb675e033e.json
Remove unused variable - `meta` is not used in `Ember.Array`. - `defineProperty` is not used in `Ember.Observable`.
packages/ember-runtime/lib/mixins/array.js
@@ -9,7 +9,7 @@ require('ember-runtime/mixins/enumerable'); // HELPERS // -var get = Ember.get, set = Ember.set, meta = Ember.meta, map = Ember.EnumerableUtils.map, cacheFor = Ember.cacheFor; +var get = Ember.get, set = Ember.set, map = Ember.EnumerableUtils.map, cacheFor = Ember.cacheFor; function none(obj) { return obj===null || obj===undefined; }
true
Other
emberjs
ember.js
0c77f3643bb9877b427d260a76f649bb675e033e.json
Remove unused variable - `meta` is not used in `Ember.Array`. - `defineProperty` is not used in `Ember.Observable`.
packages/ember-runtime/lib/mixins/observable.js
@@ -3,7 +3,7 @@ @submodule ember-runtime */ -var get = Ember.get, set = Ember.set, defineProperty = Ember.defineProperty; +var get = Ember.get, set = Ember.set; /** ## Overview
true
Other
emberjs
ember.js
f3d0fd3e0d6a3dc75d3e5e14119f295d7ced488a.json
Fix typo in Ember.String#classify doc
packages/ember-runtime/lib/system/string.js
@@ -158,7 +158,7 @@ Ember.String = { }, /** - Returns the lowerCaseCamel form of a string. + Returns the lowerCamelCase form of a string. ```javascript 'innerHTML'.camelize(); // 'innerHTML'
false
Other
emberjs
ember.js
aedbf8b2092fb03e1e71105054ce3c5a010e7cd2.json
document the init function for Ember.CoreObject
packages/ember-runtime/lib/system/core_object.js
@@ -161,6 +161,45 @@ CoreObject.PrototypeMixin = Mixin.create({ isInstance: true, + /** + An overridable method called when objects are instantiated. By default, + does nothing unless it is overridden during class definition. + + Example: + + ```javascript + App.Person = Ember.Object.extend({ + init: function() { + alert('Name is ' + this.get('name')); + } + }); + + var steve = App.Person.create({ + name: "Steve" + }); + + // alerts 'Name is Steve'. + ``` + + NOTE: If you do end override init for a framework class like `Ember.View` or + `Ember.ArrayController`, be sure to call `this._super()` in your + `init` declaration! If you don't, Ember may not have an opportunity to + do important setup work, and you'll see strange behavior in your + application. + + ```javascript + App.PersonController = Ember.ArrayController.extend({ + // called when Ember sets up an instance of your PersonController, + // or when created using App.PersonController.create() + init: function(){ + this._super(); + alert('This is how you override init'); + } + }); + ``` + + @method init + */ init: function() {}, /**
false
Other
emberjs
ember.js
4c606ac2dc11bb68d28c5e4c10543811e0f89617.json
check document before shy test
packages/ember-views/lib/system/utils.js
@@ -8,7 +8,8 @@ // Internet Explorer prior to 9 does not allow setting innerHTML if the first element // is a "zero-scope" element. This problem can be worked around by making // the first node an invisible text node. We, like Modernizr, use &shy; -var needsShy = (function(){ + +var needsShy = this.document && (function(){ var testEl = document.createElement('div'); testEl.innerHTML = "<div></div>"; testEl.firstChild.innerHTML = "<script></script>"; @@ -18,7 +19,7 @@ var needsShy = (function(){ // IE 8 (and likely earlier) likes to move whitespace preceeding // a script tag to appear after it. This means that we can // accidentally remove whitespace when updating a morph. -var movesWhitespace = (function() { +var movesWhitespace = this.document && (function() { var testEl = document.createElement('div'); testEl.innerHTML = "Test: <script type='text/x-placeholder'></script>Value"; return testEl.childNodes[0].nodeValue === 'Test:' &&
true
Other
emberjs
ember.js
4c606ac2dc11bb68d28c5e4c10543811e0f89617.json
check document before shy test
packages/metamorph/lib/main.js
@@ -9,15 +9,15 @@ define("metamorph", var K = function(){}, guid = 0, - document = window.document, + document = this.document, // Feature-detect the W3C range API, the extended check is for IE9 which only partially supports ranges - supportsRange = ('createRange' in document) && (typeof Range !== 'undefined') && Range.prototype.createContextualFragment, + supportsRange = document && ('createRange' in document) && (typeof Range !== 'undefined') && Range.prototype.createContextualFragment, // Internet Explorer prior to 9 does not allow setting innerHTML if the first element // is a "zero-scope" element. This problem can be worked around by making // the first node an invisible text node. We, like Modernizr, use &shy; - needsShy = (function(){ + needsShy = document && (function(){ var testEl = document.createElement('div'); testEl.innerHTML = "<div></div>"; testEl.firstChild.innerHTML = "<script></script>"; @@ -28,7 +28,7 @@ define("metamorph", // IE 8 (and likely earlier) likes to move whitespace preceeding // a script tag to appear after it. This means that we can // accidentally remove whitespace when updating a morph. - movesWhitespace = (function() { + movesWhitespace = document && (function() { var testEl = document.createElement('div'); testEl.innerHTML = "Test: <script type='text/x-placeholder'></script>Value"; return testEl.childNodes[0].nodeValue === 'Test:' &&
true
Other
emberjs
ember.js
68676afbbe8ab0f9169b06c5edf033c553c0e501.json
check jQuery before extending it
packages/ember-views/lib/system/jquery_ext.js
@@ -2,12 +2,13 @@ @module ember @submodule ember-views */ +if (Ember.$) { + // http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dndevents + var dragEvents = Ember.String.w('dragstart drag dragenter dragleave dragover drop dragend'); -// http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dndevents -var dragEvents = Ember.String.w('dragstart drag dragenter dragleave dragover drop dragend'); - -// Copies the `dataTransfer` property from a browser event object onto the -// jQuery event object for the specified events -Ember.EnumerableUtils.forEach(dragEvents, function(eventName) { - Ember.$.event.fixHooks[eventName] = { props: ['dataTransfer'] }; -}); + // Copies the `dataTransfer` property from a browser event object onto the + // jQuery event object for the specified events + Ember.EnumerableUtils.forEach(dragEvents, function(eventName) { + Ember.$.event.fixHooks[eventName] = { props: ['dataTransfer'] }; + }); +}
false
Other
emberjs
ember.js
2f6f06e5d1b7ab9550b060f9596a0b3d515b351e.json
remove unused function
packages/ember-runtime/tests/legacy_1x/system/object/base_test.js
@@ -26,14 +26,6 @@ var obj, obj1, don, don1 ; // global variables var get = Ember.get, set = Ember.set; -function inArray(item, array) { - var len = array.length, idx; - for (idx=0; idx<len; idx++) { - if (array[idx] === item) { return idx; } - } - return -1; -} - module("A new Ember.Object instance", { setup: function() {
false
Other
emberjs
ember.js
526f588870e5833a70c4133b4c13ed94fe751a9f.json
Add support for global mutation listeners
packages/ember-handlebars/lib/views/metamorph_view.js
@@ -11,22 +11,30 @@ require("ember-views/views/view"); var set = Ember.set, get = Ember.get; var Metamorph = requireModule('metamorph'); +function notifyMutationListeners() { + Ember.run.once(Ember.View, 'notifyMutationListeners'); +} + // DOMManager should just abstract dom manipulation between jquery and metamorph var DOMManager = { remove: function(view) { view.morph.remove(); + notifyMutationListeners(); }, prepend: function(view, html) { view.morph.prepend(html); + notifyMutationListeners(); }, after: function(view, html) { view.morph.after(html); + notifyMutationListeners(); }, html: function(view, html) { view.morph.html(html); + notifyMutationListeners(); }, // This is messed up. @@ -49,11 +57,13 @@ var DOMManager = { morph.replaceWith(buffer.string()); view.transitionTo('inDOM'); view.triggerRecursively('didInsertElement'); + notifyMutationListeners(); }); }, empty: function(view) { view.morph.html(""); + notifyMutationListeners(); } };
true
Other
emberjs
ember.js
526f588870e5833a70c4133b4c13ed94fe751a9f.json
Add support for global mutation listeners
packages/ember-handlebars/tests/controls/checkbox_test.js
@@ -73,7 +73,7 @@ test("checked property mirrors input value", function() { equal(checkboxView.$().prop('checked'), true, "changing the value property changes the DOM"); - checkboxView.remove(); + Ember.run(function() { checkboxView.remove(); }); Ember.run(function() { checkboxView.append(); }); equal(checkboxView.$().prop('checked'), true, "changing the value property changes the DOM");
true
Other
emberjs
ember.js
526f588870e5833a70c4133b4c13ed94fe751a9f.json
Add support for global mutation listeners
packages/ember-routing/lib/helpers/shared.js
@@ -8,13 +8,15 @@ Ember.onLoad('Ember.Handlebars', function() { function resolveParams(context, params, options) { var resolved = handlebarsResolve(context, params, options); return map.call(resolved, unwrap); - } - function unwrap(object) { - if (Ember.ControllerMixin.detect(object)) { - return unwrap(get(object, 'model')); - } else { - return object; + function unwrap(object, i) { + if (params[i] === 'controller') { return object; } + + if (Ember.ControllerMixin.detect(object)) { + return unwrap(get(object, 'model')); + } else { + return object; + } } }
true
Other
emberjs
ember.js
526f588870e5833a70c4133b4c13ed94fe751a9f.json
Add support for global mutation listeners
packages/ember-views/lib/views/view.js
@@ -2187,17 +2187,24 @@ Ember.View = Ember.CoreView.extend( // once the view has been inserted into the DOM, legal manipulations // are done on the DOM element. +function notifyMutationListeners() { + Ember.run.once(Ember.View, 'notifyMutationListeners'); +} + var DOMManager = { prepend: function(view, html) { view.$().prepend(html); + notifyMutationListeners(); }, after: function(view, html) { view.$().after(html); + notifyMutationListeners(); }, html: function(view, html) { view.$().html(html); + notifyMutationListeners(); }, replace: function(view) { @@ -2207,15 +2214,18 @@ var DOMManager = { view._insertElementLater(function() { Ember.$(element).replaceWith(get(view, 'element')); + notifyMutationListeners(); }); }, remove: function(view) { view.$().remove(); + notifyMutationListeners(); }, empty: function(view) { view.$().empty(); + notifyMutationListeners(); } }; @@ -2330,6 +2340,20 @@ Ember.View.reopenClass({ } }); +var mutation = Ember.Object.extend(Ember.Evented).create(); + +Ember.View.addMutationListener = function(callback) { + mutation.on('change', callback); +}; + +Ember.View.removeMutationListener = function(callback) { + mutation.off('change', callback); +}; + +Ember.View.notifyMutationListeners = function() { + mutation.trigger('change'); +}; + /** Global views hash
true
Other
emberjs
ember.js
526f588870e5833a70c4133b4c13ed94fe751a9f.json
Add support for global mutation listeners
packages/ember-views/tests/views/view/is_visible_test.js
@@ -51,7 +51,9 @@ test("should hide views when isVisible is false", function() { set(view, 'isVisible', true); ok(view.$().is(':visible'), "the view is visible"); - view.remove(); + Ember.run(function() { + view.remove(); + }); }); test("should hide element if isVisible is false before element is created", function() { @@ -69,7 +71,10 @@ test("should hide element if isVisible is false before element is created", func ok(view.$().is(':hidden'), "should be hidden"); - view.remove(); + Ember.run(function() { + view.remove(); + }); + set(view, 'isVisible', true); Ember.run(function() {
true
Other
emberjs
ember.js
526f588870e5833a70c4133b4c13ed94fe751a9f.json
Add support for global mutation listeners
packages/ember-views/tests/views/view/remove_test.js
@@ -89,7 +89,10 @@ test("removes view from parent view", function() { ok(parentView.$('div').length, "precond - has a child DOM element"); - child.removeFromParent(); + Ember.run(function() { + child.removeFromParent(); + }); + ok(!get(child, 'parentView'), 'no longer has parentView'); ok(indexOf(get(parentView, 'childViews'), child)<0, 'no longer in parent childViews'); equal(parentView.$('div').length, 0, "removes DOM element from parent"); @@ -98,7 +101,11 @@ test("removes view from parent view", function() { test("returns receiver", function() { parentView = Ember.ContainerView.create({ childViews: [Ember.View] }); child = get(parentView, 'childViews').objectAt(0); - equal(child.removeFromParent(), child, 'receiver'); + var removed = Ember.run(function() { + return child.removeFromParent(); + }); + + equal(removed, child, 'receiver'); }); test("does nothing if not in parentView", function() {
true
Other
emberjs
ember.js
d433d59690eac9a368432e01324d6424a3480d95.json
expose RSVP on the ember namespace
packages/ember-runtime/lib/ext.js
@@ -1,2 +1,3 @@ +require('ember-runtime/ext/ember'); require('ember-runtime/ext/string'); require('ember-runtime/ext/function');
true
Other
emberjs
ember.js
d433d59690eac9a368432e01324d6424a3480d95.json
expose RSVP on the ember namespace
packages/ember-runtime/lib/ext/ember.js
@@ -0,0 +1,8 @@ +/** + Expose RSVP implementation + + @class RSVP + @namespace Ember + @constructor +*/ +Ember.RSVP = requireModule('rsvp');
true
Other
emberjs
ember.js
eedefb4183249eaf8c29d8ebb6dce78113bccc52.json
Reuse path variable
packages/ember-routing/lib/location/hash_location.js
@@ -67,7 +67,7 @@ Ember.HashLocation = Ember.Object.extend({ set(self, 'lastSetURL', null); - callback(location.hash.substr(1)); + callback(path); }); }); },
false
Other
emberjs
ember.js
532dec210363bc7f412eb2ac5bef9e8a9adc52fd.json
Normalize controller lookup, fix #2025
packages/container/lib/main.js
@@ -76,7 +76,6 @@ define("container", register: function(type, name, factory, options) { var fullName; - if (type.indexOf(':') !== -1){ options = factory; factory = name; @@ -86,14 +85,20 @@ define("container", fullName = type + ":" + name; } - this.registry.set(fullName, factory); - this._options.set(fullName, options || {}); + var normalizedName = this.normalize(fullName); + + this.registry.set(normalizedName, factory); + this._options.set(normalizedName, options || {}); }, resolve: function(fullName) { return this.resolver(fullName) || this.registry.get(fullName); }, + normalize: function(fullName) { + return fullName; + }, + lookup: function(fullName, options) { options = options || {}; @@ -223,7 +228,8 @@ define("container", } function factoryFor(container, fullName) { - return container.resolve(fullName); + var name = container.normalize(fullName); + return container.resolve(name); } function instantiate(container, fullName) {
true
Other
emberjs
ember.js
532dec210363bc7f412eb2ac5bef9e8a9adc52fd.json
Normalize controller lookup, fix #2025
packages/container/tests/container_test.js
@@ -225,6 +225,20 @@ test("The container respect the resolver hook for `has`", function() { ok(container.has('controller:post'), "the `has` method uses the resolver hook"); }); +test("The container normalizes names before resolving", function() { + var container = new Container(); + var PostController = factory(); + + container.normalize = function(fullName) { + return 'controller:post'; + }; + + container.register('controller:post', PostController); + var postController = container.lookup('wycats'); + + ok(postController instanceof PostController, "Normalizes the name before resolving"); +}); + test("The container can get options that should be applied to all factories for a given type", function() { var container = new Container(); var PostView = factory();
true
Other
emberjs
ember.js
532dec210363bc7f412eb2ac5bef9e8a9adc52fd.json
Normalize controller lookup, fix #2025
packages/ember-application/lib/system/application.js
@@ -594,6 +594,7 @@ Ember.Application.reopenClass({ Ember.Container.defaultContainer = Ember.Container.defaultContainer || container; container.set = Ember.set; + container.normalize = normalize; container.resolver = resolverFor(namespace); container.optionsForType('view', { singleton: false }); container.optionsForType('template', { instantiate: false }); @@ -633,6 +634,7 @@ function resolverFor(namespace) { if (type === 'template') { var templateName = name.replace(/\./g, '/'); + if (Ember.TEMPLATES[templateName]) { return Ember.TEMPLATES[templateName]; } @@ -663,5 +665,16 @@ function resolverFor(namespace) { }; } -Ember.runLoadHooks('Ember.Application', Ember.Application); +function normalize(fullName) { + var split = fullName.split(':'), + type = split[0], + name = split[1]; + + if (type !== 'template' && name.indexOf('.') > -1) { + return type + ':' + name.replace(/\.(.)/g, function(m) { return m[1].toUpperCase(); }); + } else { + return fullName; + } +} +Ember.runLoadHooks('Ember.Application', Ember.Application);
true
Other
emberjs
ember.js
532dec210363bc7f412eb2ac5bef9e8a9adc52fd.json
Normalize controller lookup, fix #2025
packages/ember-application/tests/system/application_test.js
@@ -233,15 +233,17 @@ module("Ember.Application Depedency Injection", { application = Ember.Application.create().initialize(); }); - application.Person = Ember.Object.extend({}); - application.Orange = Ember.Object.extend({}); - application.Email = Ember.Object.extend({}); - application.User = Ember.Object.extend({}); + application.Person = Ember.Object.extend({}); + application.Orange = Ember.Object.extend({}); + application.Email = Ember.Object.extend({}); + application.User = Ember.Object.extend({}); + application.PostIndexController = Ember.Object.extend({}); application.register('model:person', application.Person, {singleton: false }); application.register('model:user', application.User, {singleton: false }); application.register('fruit:favorite', application.Orange); application.register('communication:main', application.Email, {singleton: false}); + application.register('controller:postIndex', application.PostIndexController, {singleton: true}); locator = application.__container__; @@ -256,16 +258,23 @@ module("Ember.Application Depedency Injection", { } }); +test('container lookup is normalized', function() { + ok(locator.lookup('controller:post.index') instanceof application.PostIndexController); + ok(locator.lookup('controller:postIndex') instanceof application.PostIndexController); +}); + test('registered entities can be looked up later', function(){ equal(locator.resolve('model:person'), application.Person); equal(locator.resolve('model:user'), application.User); equal(locator.resolve('fruit:favorite'), application.Orange); equal(locator.resolve('communication:main'), application.Email); + equal(locator.resolve('controller:postIndex'), application.PostIndexController); equal(locator.lookup('fruit:favorite'), locator.lookup('fruit:favorite'), 'singleton lookup worked'); ok(locator.lookup('model:user') !== locator.lookup('model:user'), 'non-singleton lookup worked'); }); + test('injections', function(){ application.inject('model', 'fruit', 'fruit:favorite'); application.inject('model:user', 'communication', 'communication:main');
true
Other
emberjs
ember.js
532dec210363bc7f412eb2ac5bef9e8a9adc52fd.json
Normalize controller lookup, fix #2025
packages/ember-application/tests/system/controller_test.js
@@ -26,4 +26,3 @@ test("If a controller specifies an unavailable dependency, it raises", function( container.lookup('controller:post'); }, /controller:posts/); }); -
true
Other
emberjs
ember.js
17b2dcda78c5336ac2bc958a3a1b4c82446e60bb.json
Move resolution logic to shared file
packages/ember-routing/lib/helpers.js
@@ -1,3 +1,4 @@ +require('ember-routing/helpers/shared'); require('ember-routing/helpers/link_to'); require('ember-routing/helpers/outlet'); require('ember-routing/helpers/render');
true
Other
emberjs
ember.js
17b2dcda78c5336ac2bc958a3a1b4c82446e60bb.json
Move resolution logic to shared file
packages/ember-routing/lib/helpers/action.js
@@ -9,28 +9,14 @@ require('ember-handlebars/helpers/view'); Ember.onLoad('Ember.Handlebars', function(Handlebars) { - var resolveParams = Ember.Handlebars.resolveParams, + var resolveParams = Ember.Router.resolveParams, isSimpleClick = Ember.ViewUtils.isSimpleClick; var EmberHandlebars = Ember.Handlebars, handlebarsGet = EmberHandlebars.get, SafeString = EmberHandlebars.SafeString, get = Ember.get, - a_slice = Array.prototype.slice, - map = Ember.ArrayPolyfills.map; - - function resolveAndUnwrap(context, params, options) { - var resolved = resolveParams(context, params, options); - return map.call(resolved, unwrap); - } - - function unwrap(object) { - if (Ember.ControllerMixin.detect(object)) { - return unwrap(get(object, 'model')); - } else { - return object; - } - } + a_slice = Array.prototype.slice; function args(options, actionName) { var ret = []; @@ -39,7 +25,7 @@ Ember.onLoad('Ember.Handlebars', function(Handlebars) { var types = options.options.types.slice(1), data = options.options.data; - return ret.concat(resolveAndUnwrap(options.context, options.params, { types: types, data: data })); + return ret.concat(resolveParams(options.context, options.params, { types: types, data: data })); } var ActionHelper = EmberHandlebars.ActionHelper = {
true
Other
emberjs
ember.js
17b2dcda78c5336ac2bc958a3a1b4c82446e60bb.json
Move resolution logic to shared file
packages/ember-routing/lib/helpers/shared.js
@@ -0,0 +1,22 @@ +require('ember-routing/system/router'); + +Ember.onLoad('Ember.Handlebars', function() { + var handlebarsResolve = Ember.Handlebars.resolveParams, + map = Ember.ArrayPolyfills.map, + get = Ember.get; + + function resolveParams(context, params, options) { + var resolved = handlebarsResolve(context, params, options); + return map.call(resolved, unwrap); + } + + function unwrap(object) { + if (Ember.ControllerMixin.detect(object)) { + return unwrap(get(object, 'model')); + } else { + return object; + } + } + + Ember.Router.resolveParams = resolveParams; +});
true
Other
emberjs
ember.js
5f43e5bee2ac922240ad4d2c4bd0e218777e784e.json
Fix typo in _resetSubControllers
packages/ember-runtime/lib/controllers/array_controller.js
@@ -207,7 +207,7 @@ Ember.ArrayController = Ember.ArrayProxy.extend(Ember.ControllerMixin, var subControllers = get(this, '_subControllers'); forEach(subControllers, function(subController) { - if (subControllers) { subController.destroy(); } + if (subController) { subController.destroy(); } }); this.set('_subControllers', Ember.A());
false
Other
emberjs
ember.js
37d7f49150008193d8ad5b14c3916b89ddc14e83.json
Fix broken link in code comment
packages/ember-old-router/lib/application/system/application.js
@@ -93,7 +93,7 @@ var get = Ember.get, set = Ember.set; To learn more about the advantages of event delegation and the Ember view layer, and a list of the event listeners that are setup by default, visit the - [Ember View Layer guide](http://emberjs.com/guides/view_layer#toc_event-delegation). + [Ember View Layer guide](http://emberjs.com/guides/understanding-ember/the-view-layer/#toc_event-delegation). ### Dependency Injection
false
Other
emberjs
ember.js
47ff6316a2a00e8ddd375f7c9a009797b051be43.json
Fix missing reuturn in CollectionView docs `createChildView` has to return the call to `this._super`, otherwise everything breaks.
packages/ember-views/lib/views/collection_view.js
@@ -110,7 +110,7 @@ var get = Ember.get, set = Ember.set, fmt = Ember.String.fmt; } else { viewClass = App.SongView; } - this._super(viewClass, attrs); + return this._super(viewClass, attrs); } }); ```
false
Other
emberjs
ember.js
5e20dcc7248a5cfd31414415ceaf9db61533dea2.json
Add missing arguments in code comment
packages/ember-metal/lib/events.js
@@ -109,6 +109,7 @@ function actionsDiff(obj, eventName, otherActions) { @param {String} eventName @param {Object|Function} targetOrMethod A target object or a function @param {Function|String} method A function or the name of a function to be called on `target` + @param {Boolean} once A flag whether a function should only be called once */ function addListener(obj, eventName, target, method, once) { Ember.assert("You must pass at least an object and event name to Ember.addListener", !!obj && !!eventName); @@ -294,6 +295,7 @@ function watchedEvents(obj) { @param obj @param {String} eventName @param {Array} params + @param {Array} actions @return true */ function sendEvent(obj, eventName, params, actions) {
false
Other
emberjs
ember.js
c19dcf8009961977c7c6d0305b84542e9ae65393.json
Fix code comment - Add missing arguments - Fix order of type and argument name - Fix argument name
packages/ember-metal/lib/accessors.js
@@ -290,7 +290,7 @@ Ember.setPath = Ember.deprecateFunc('setPath is deprecated since set now support @method trySet @for Ember @param {Object} obj The object to modify. - @param {String} keyName The property key to set + @param {String} path The property path to set @param {Object} value The value to set */ Ember.trySet = function(root, path, value) {
true
Other
emberjs
ember.js
c19dcf8009961977c7c6d0305b84542e9ae65393.json
Fix code comment - Add missing arguments - Fix order of type and argument name - Fix argument name
packages/ember-metal/lib/binding.js
@@ -78,7 +78,7 @@ Binding.prototype = { `get()` - see that method for more information. @method from - @param {String} propertyPath the property path to connect to + @param {String} path the property path to connect to @return {Ember.Binding} `this` */ from: function(path) { @@ -96,7 +96,7 @@ Binding.prototype = { `get()` - see that method for more information. @method to - @param {String|Tuple} propertyPath A property path or tuple + @param {String|Tuple} path A property path or tuple @return {Ember.Binding} `this` */ to: function(path) {
true
Other
emberjs
ember.js
c19dcf8009961977c7c6d0305b84542e9ae65393.json
Fix code comment - Add missing arguments - Fix order of type and argument name - Fix argument name
packages/ember-metal/lib/map.js
@@ -136,8 +136,8 @@ OrderedSet.prototype = { /** @method forEach - @param {Function} function - @param target + @param {Function} fn + @param self */ forEach: function(fn, self) { // allow mutation during iteration
true
Other
emberjs
ember.js
c19dcf8009961977c7c6d0305b84542e9ae65393.json
Fix code comment - Add missing arguments - Fix order of type and argument name - Fix argument name
packages/ember-metal/lib/utils.js
@@ -80,7 +80,7 @@ Ember.generateGuid = function generateGuid(obj, prefix) { @method guidFor @for Ember - @param obj {Object} any object, string, number, Element, or primitive + @param {Object} obj any object, string, number, Element, or primitive @return {String} the unique guid for this instance. */ Ember.guidFor = function guidFor(obj) { @@ -430,8 +430,8 @@ var needsFinallyFix = (function() { @method tryFinally @for Ember - @param {Function} function The function to run the try callback - @param {Function} function The function to run the finally callback + @param {Function} tryable The function to run the try callback + @param {Function} finalizer The function to run the finally callback @param [binding] @return {anything} The return value is the that of the finalizer, unless that valueis undefined, in which case it is the return value @@ -480,9 +480,9 @@ if (needsFinallyFix) { @method tryCatchFinally @for Ember - @param {Function} function The function to run the try callback - @param {Function} function The function to run the catchable callback - @param {Function} function The function to run the finally callback + @param {Function} tryable The function to run the try callback + @param {Function} catchable The function to run the catchable callback + @param {Function} finalizer The function to run the finally callback @param [binding] @return {anything} The return value is the that of the finalizer, unless that value is undefined, in which case it is the return value
true
Other
emberjs
ember.js
c19dcf8009961977c7c6d0305b84542e9ae65393.json
Fix code comment - Add missing arguments - Fix order of type and argument name - Fix argument name
packages/ember-runtime/lib/core.js
@@ -63,7 +63,7 @@ var toString = Object.prototype.toString; @method typeOf @for Ember - @param item {Object} the item to check + @param {Object} item the item to check @return {String} the type */ Ember.typeOf = function(item) { @@ -297,7 +297,7 @@ function _copy(obj, deep, seen, copies) { @method copy @for Ember - @param {Object} object The object to clone + @param {Object} obj The object to clone @param {Boolean} deep If true, a deep copy of the object is made @return {Object} The cloned object */
true
Other
emberjs
ember.js
c19dcf8009961977c7c6d0305b84542e9ae65393.json
Fix code comment - Add missing arguments - Fix order of type and argument name - Fix argument name
packages/ember-runtime/lib/mixins/array.js
@@ -257,7 +257,7 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot @method addArrayObserver @param {Object} target The observer object. @param {Hash} opts Optional hash of configuration options including - `willChange`, `didChange`, and a `context` option. + `willChange` and `didChange` option. @return {Ember.Array} receiver */ addArrayObserver: function(target, opts) { @@ -279,6 +279,8 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot @method removeArrayObserver @param {Object} target The object observing the array. + @param {Hash} opts Optional hash of configuration options including + `willChange` and `didChange` option. @return {Ember.Array} receiver */ removeArrayObserver: function(target, opts) {
true
Other
emberjs
ember.js
c19dcf8009961977c7c6d0305b84542e9ae65393.json
Fix code comment - Add missing arguments - Fix order of type and argument name - Fix argument name
packages/ember-runtime/lib/mixins/copyable.js
@@ -33,7 +33,7 @@ Ember.Copyable = Ember.Mixin.create( an exception. @method copy - @param deep {Boolean} if `true`, a deep copy of the object should be made + @param {Boolean} deep if `true`, a deep copy of the object should be made @return {Object} copy of receiver */ copy: Ember.required(Function),
true
Other
emberjs
ember.js
c19dcf8009961977c7c6d0305b84542e9ae65393.json
Fix code comment - Add missing arguments - Fix order of type and argument name - Fix argument name
packages/ember-runtime/lib/mixins/enumerable.js
@@ -730,8 +730,8 @@ Ember.Enumerable = Ember.Mixin.create( mixin. @method addEnumerableObserver - @param target {Object} - @param opts {Hash} + @param {Object} target + @param {Hash} opts */ addEnumerableObserver: function(target, opts) { var willChange = (opts && opts.willChange) || 'enumerableWillChange', @@ -749,8 +749,8 @@ Ember.Enumerable = Ember.Mixin.create( Removes a registered enumerable observer. @method removeEnumerableObserver - @param target {Object} - @param [opts] {Hash} + @param {Object} target + @param {Hash} [opts] */ removeEnumerableObserver: function(target, opts) { var willChange = (opts && opts.willChange) || 'enumerableWillChange',
true
Other
emberjs
ember.js
c19dcf8009961977c7c6d0305b84542e9ae65393.json
Fix code comment - Add missing arguments - Fix order of type and argument name - Fix argument name
packages/ember-runtime/lib/mixins/observable.js
@@ -108,7 +108,7 @@ Ember.Observable = Ember.Mixin.create(/** @scope Ember.Observable.prototype */ { not defined upfront. @method get - @param {String} key The property to retrieve + @param {String} keyName The property to retrieve @return {Object} The property value or undefined. */ get: function(keyName) { @@ -189,7 +189,7 @@ Ember.Observable = Ember.Mixin.create(/** @scope Ember.Observable.prototype */ { ``` @method set - @param {String} key The property to set + @param {String} keyName The property to set @param {Object} value The value to set or `null`. @return {Ember.Observable} */ @@ -266,7 +266,7 @@ Ember.Observable = Ember.Mixin.create(/** @scope Ember.Observable.prototype */ { like. @method propertyWillChange - @param {String} key The property key that is about to change. + @param {String} keyName The property key that is about to change. @return {Ember.Observable} */ propertyWillChange: function(keyName){
true
Other
emberjs
ember.js
1de089bdbbff3dde332034e4e7c9d5fa4ac1569b.json
Remove unused variables
packages/container/lib/main.js
@@ -2,12 +2,6 @@ define("container", [], function() { - var objectCreate = Object.create || function(parent) { - function F() {} - F.prototype = parent; - return new F(); - }; - function InheritingDict(parent) { this.parent = parent; this.dict = {};
true
Other
emberjs
ember.js
1de089bdbbff3dde332034e4e7c9d5fa4ac1569b.json
Remove unused variables
packages/ember-handlebars/lib/loader.js
@@ -30,8 +30,7 @@ Ember.Handlebars.bootstrap = function(ctx) { Ember.$(selectors, ctx) .each(function() { // Get a reference to the script tag - var script = Ember.$(this), - type = script.attr('type'); + var script = Ember.$(this); var compile = (script.attr('type') === 'text/x-raw-handlebars') ? Ember.$.proxy(Handlebars.compile, Handlebars) :
true
Other
emberjs
ember.js
778f5a069a4027a85ab659645edca592d857732b.json
Remove reference to therubyracer from README.md therubyracer doesn't currently work to build ember.js, and this patch removes an instruction to use it.
README.md
@@ -100,8 +100,9 @@ NOTE: Due to the rename, these instructions may be in flux builds of Ember.js If you are building under Linux, you will need a JavaScript runtime for -minification. You can either install nodejs or `gem install -therubyracer`. +minification, for which we recommend installing nodejs. Alternatively +you may have luck with another of the runtimes supported by +[execjs](https://github.com/sstephenson/execjs). # How to Run Unit Tests
false
Other
emberjs
ember.js
c87cc34c015753904e96c35143c37f4d2fc63054.json
Fix broken link
packages/ember-application/lib/system/application.js
@@ -96,7 +96,7 @@ var get = Ember.get, set = Ember.set, To learn more about the advantages of event delegation and the Ember view layer, and a list of the event listeners that are setup by default, visit the - [Ember View Layer guide](http://emberjs.com/guides/view_layer#toc_event-delegation). + [Ember View Layer guide](http://emberjs.com/guides/understanding-ember/the-view-layer/#toc_event-delegation). ### Initializers
false
Other
emberjs
ember.js
f78d6a1b4986b8d846d78b21fe7a8aa844ed83d5.json
Add support for /-separated namespace lookup The default resolver hook now supports names like "controller:foo/bar", which resolves to Foo.BarController, assuming Foo is a registered namespace.
packages/ember-application/lib/system/application.js
@@ -5,6 +5,7 @@ var get = Ember.get, set = Ember.set, classify = Ember.String.classify, + capitalize = Ember.String.capitalize, decamelize = Ember.String.decamelize; /** @@ -644,7 +645,8 @@ Ember.Application.reopenClass({ function resolverFor(namespace) { return function(fullName) { var nameParts = fullName.split(":"), - type = nameParts[0], name = nameParts[1]; + type = nameParts[0], name = nameParts[1], + root = namespace; if (type === 'template') { var templateName = name.replace(/\./g, '/'); @@ -662,8 +664,17 @@ function resolverFor(namespace) { name = name.replace(/\./g, '_'); } + if (type !== 'template' && name.indexOf('/') !== -1) { + var parts = name.split('/'); + name = parts[parts.length - 1]; + var namespaceName = capitalize(parts.slice(0, -1).join('.')); + root = Ember.Namespace.byName(namespaceName); + + Ember.assert('You are looking for a ' + name + ' ' + type + ' in the ' + namespaceName + ' namespace, but it could not be found', root); + } + var className = classify(name) + classify(type); - var factory = get(namespace, className); + var factory = get(root, className); if (factory) { return factory; } };
true
Other
emberjs
ember.js
f78d6a1b4986b8d846d78b21fe7a8aa844ed83d5.json
Add support for /-separated namespace lookup The default resolver hook now supports names like "controller:foo/bar", which resolves to Foo.BarController, assuming Foo is a registered namespace.
packages/ember-application/tests/system/application_test.js
@@ -217,7 +217,8 @@ test("Minimal Application initialized with just an application template", functi equal(trim(Ember.$('#qunit-fixture').text()), 'Hello World'); }); -var locator; +var locator, originalLookup = Ember.lookup, lookup; + module("Ember.Application Depedency Injection", { setup: function(){ Ember.run(function(){ @@ -235,12 +236,15 @@ module("Ember.Application Depedency Injection", { application.register('communication:main', application.Email, {singleton: false}); locator = application.__container__; + + lookup = Ember.lookup = {}; }, teardown: function() { Ember.run(function(){ application.destroy(); }); application = locator = null; + Ember.lookup = originalLookup; } }); @@ -267,3 +271,12 @@ test('injections', function(){ ok(application.Email.detectInstance(user.get('communication'))); }); + +test('the default resolver hook can look things up in other namespaces', function() { + var UserInterface = lookup.UserInterface = Ember.Namespace.create(); + UserInterface.NavigationController = Ember.Controller.extend(); + + var nav = locator.lookup('controller:userInterface/navigation'); + + ok(nav instanceof UserInterface.NavigationController, "the result should be an instance of the specified class"); +});
true
Other
emberjs
ember.js
8e13610d210cb024894656cce57e06a48ed96944.json
Hide {{control}} behind a flag - Fixes #2073
packages/ember-routing/lib/helpers/control.js
@@ -3,68 +3,72 @@ @submodule ember-routing */ +if (Ember.ENV.EXPERIMENTAL_CONTROL_HELPER) { + var get = Ember.get, set = Ember.set; -var get = Ember.get, set = Ember.set; + /** + The control helper is currently under development and is considered experimental. + To enable it, set `ENV.EXPERIMENTAL_CONTROL_HELPER = true` before requiring Ember. -/** - @method control - @for Ember.Handlebars.helpers - @param {String} path - @param {String} modelPath - @param {Hash} options - @return {String} HTML string -*/ -Ember.Handlebars.registerHelper('control', function(path, modelPath, options) { - if (arguments.length === 2) { - options = modelPath; - modelPath = undefined; - } + @method control + @for Ember.Handlebars.helpers + @param {String} path + @param {String} modelPath + @param {Hash} options + @return {String} HTML string + */ + Ember.Handlebars.registerHelper('control', function(path, modelPath, options) { + if (arguments.length === 2) { + options = modelPath; + modelPath = undefined; + } + + var model; - var model; + if (modelPath) { + model = Ember.Handlebars.get(this, modelPath, options); + } - if (modelPath) { - model = Ember.Handlebars.get(this, modelPath, options); - } + var controller = options.data.keywords.controller, + view = options.data.keywords.view, + children = get(controller, '_childContainers'), + controlID = options.hash.controlID, + container, subContainer; - var controller = options.data.keywords.controller, - view = options.data.keywords.view, - children = get(controller, '_childContainers'), - controlID = options.hash.controlID, - container, subContainer; + if (children.hasOwnProperty(controlID)) { + subContainer = children[controlID]; + } else { + container = get(controller, 'container'), + subContainer = container.child(); + children[controlID] = subContainer; + } - if (children.hasOwnProperty(controlID)) { - subContainer = children[controlID]; - } else { - container = get(controller, 'container'), - subContainer = container.child(); - children[controlID] = subContainer; - } + var normalizedPath = path.replace(/\//g, '.'); - var normalizedPath = path.replace(/\//g, '.'); + var childView = subContainer.lookup('view:' + normalizedPath) || subContainer.lookup('view:default'), + childController = subContainer.lookup('controller:' + normalizedPath), + childTemplate = subContainer.lookup('template:' + path); - var childView = subContainer.lookup('view:' + normalizedPath) || subContainer.lookup('view:default'), - childController = subContainer.lookup('controller:' + normalizedPath), - childTemplate = subContainer.lookup('template:' + path); + Ember.assert("Could not find controller for path: " + normalizedPath, childController); + Ember.assert("Could not find view for path: " + normalizedPath, childView); - Ember.assert("Could not find controller for path: " + normalizedPath, childController); - Ember.assert("Could not find view for path: " + normalizedPath, childView); + set(childController, 'target', controller); + set(childController, 'model', model); - set(childController, 'target', controller); - set(childController, 'model', model); + options.hash.template = childTemplate; + options.hash.controller = childController; - options.hash.template = childTemplate; - options.hash.controller = childController; + function observer() { + var model = Ember.Handlebars.get(this, modelPath, options); + set(childController, 'model', model); + childView.rerender(); + } - function observer() { - var model = Ember.Handlebars.get(this, modelPath, options); - set(childController, 'model', model); - childView.rerender(); - } + Ember.addObserver(this, modelPath, observer); + childView.one('willDestroyElement', this, function() { + Ember.removeObserver(this, modelPath, observer); + }); - Ember.addObserver(this, modelPath, observer); - childView.one('willDestroyElement', this, function() { - Ember.removeObserver(this, modelPath, observer); + Ember.Handlebars.helpers.view.call(this, childView, options); }); - - Ember.Handlebars.helpers.view.call(this, childView, options); -}); +}
true
Other
emberjs
ember.js
8e13610d210cb024894656cce57e06a48ed96944.json
Hide {{control}} behind a flag - Fixes #2073
packages/ember-routing/tests/helpers/control_test.js
@@ -1,22 +1,6 @@ /*global QUnit*/ -var container, view; - -module("Handlebars {{control}} helper", { - setup: function() { - container = new Ember.Container(); - container.options('template', { instantiate: false }); - container.options('view', { singleton: false }); - container.register('controller:parent', Ember.Controller.extend()); - container.register('controller:widget', Ember.Controller.extend()); - container.register('view:widget', Ember.View.extend()); - }, - - teardown: function() { - destroy(view); - destroy(container); - } -}); +var container, view; var compile = Ember.Handlebars.compile; function destroy(object) { @@ -37,213 +21,231 @@ function renderedText(expected, msg) { QUnit.push(actual === expected, actual, expected, msg); } -test("A control raises an error when a view cannot be found", function() { - container = new Ember.Container(); - container.options('template', { instantiate: false }); - container.options('view', { singleton: false }); - container.register('controller:parent', Ember.Controller.extend()); - container.register('controller:widget', Ember.Controller.extend()); - container.register('template:widget', compile("Hello")); +if (Ember.ENV.EXPERIMENTAL_CONTROL_HELPER) { + module("Handlebars {{control}} helper", { + setup: function() { + container = new Ember.Container(); + container.options('template', { instantiate: false }); + container.options('view', { singleton: false }); + container.register('controller:parent', Ember.Controller.extend()); + container.register('controller:widget', Ember.Controller.extend()); + container.register('view:widget', Ember.View.extend()); + }, + + teardown: function() { + destroy(view); + destroy(container); + } + }); - throws(function() { - appendView({ - controller: container.lookup('controller:parent'), - template: compile("{{control widget}}") + test("A control raises an error when a view cannot be found", function() { + container = new Ember.Container(); + container.options('template', { instantiate: false }); + container.options('view', { singleton: false }); + container.register('controller:parent', Ember.Controller.extend()); + container.register('controller:widget', Ember.Controller.extend()); + container.register('template:widget', compile("Hello")); + + throws(function() { + appendView({ + controller: container.lookup('controller:parent'), + template: compile("{{control widget}}") + }); + }, /find view/, "Must raise an error if no view is defined"); + }); + + test("A control raises an error when a controller cannot be found", function() { + container = new Ember.Container(); + container.options('template', { instantiate: false }); + container.options('view', { singleton: false }); + container.register('controller:parent', Ember.Controller.extend()); + container.register('view:widget', Ember.View.extend()); + container.register('template:widget', compile("Hello")); + + throws(function() { + appendView({ + controller: container.lookup('controller:parent'), + template: compile("{{control widget}}") + }); + }, /find controller/, "Must raise an error when no controller is defined"); + + // The assertion causes some views to be left behind + Ember.run(function() { + for (var viewId in Ember.View.views) { + Ember.View.views[viewId].destroy(); + } }); - }, /find view/, "Must raise an error if no view is defined"); -}); + }); -test("A control raises an error when a controller cannot be found", function() { - container = new Ember.Container(); - container.options('template', { instantiate: false }); - container.options('view', { singleton: false }); - container.register('controller:parent', Ember.Controller.extend()); - container.register('view:widget', Ember.View.extend()); - container.register('template:widget', compile("Hello")); + test("A control renders a template with a new instance of the named controller and view", function() { + container.register('template:widget', compile("Hello")); - throws(function() { appendView({ controller: container.lookup('controller:parent'), template: compile("{{control widget}}") }); - }, /find controller/, "Must raise an error when no controller is defined"); - // The assertion causes some views to be left behind - Ember.run(function() { - for (var viewId in Ember.View.views) { - Ember.View.views[viewId].destroy(); - } + renderedText("Hello"); }); -}); -test("A control renders a template with a new instance of the named controller and view", function() { - container.register('template:widget', compile("Hello")); + test("A control's controller and view are lookuped up via template name", function() { + container.register('template:widgets/foo', compile("Hello")); + container.register('controller:widgets.foo', Ember.Controller.extend()); + container.register('view:widgets.foo', Ember.View.extend()); - appendView({ - controller: container.lookup('controller:parent'), - template: compile("{{control widget}}") - }); - - renderedText("Hello"); -}); - -test("A control's controller and view are lookuped up via template name", function() { - container.register('template:widgets/foo', compile("Hello")); - container.register('controller:widgets.foo', Ember.Controller.extend()); - container.register('view:widgets.foo', Ember.View.extend()); + appendView({ + controller: container.lookup('controller:parent'), + template: compile("{{control 'widgets/foo'}}") + }); - appendView({ - controller: container.lookup('controller:parent'), - template: compile("{{control 'widgets/foo'}}") + renderedText("Hello"); }); - renderedText("Hello"); -}); + test("A control defaults to the default view", function() { + container.register('template:widgets/foo', compile("Hello")); + container.register('controller:widgets.foo', Ember.Controller.extend()); + container.register('view:default', Ember.View.extend()); -test("A control defaults to the default view", function() { - container.register('template:widgets/foo', compile("Hello")); - container.register('controller:widgets.foo', Ember.Controller.extend()); - container.register('view:default', Ember.View.extend()); + appendView({ + controller: container.lookup('controller:parent'), + template: compile("{{control 'widgets/foo'}}") + }); - appendView({ - controller: container.lookup('controller:parent'), - template: compile("{{control 'widgets/foo'}}") + renderedText("Hello"); }); - renderedText("Hello"); -}); + test("A control with a default view survives re-render", function() { + container.register('template:widgets/foo', compile("Hello")); + container.register('controller:widgets.foo', Ember.Controller.extend()); + container.register('view:default', Ember.View.extend()); -test("A control with a default view survives re-render", function() { - container.register('template:widgets/foo', compile("Hello")); - container.register('controller:widgets.foo', Ember.Controller.extend()); - container.register('view:default', Ember.View.extend()); + appendView({ + controller: container.lookup('controller:parent'), + template: compile("{{control 'widgets/foo'}}") + }); - appendView({ - controller: container.lookup('controller:parent'), - template: compile("{{control 'widgets/foo'}}") - }); + renderedText("Hello"); - renderedText("Hello"); + Ember.run(function() { + view.rerender(); + }); - Ember.run(function() { - view.rerender(); + renderedText("Hello"); }); - renderedText("Hello"); -}); + test("A control can specify a model to use in its template", function() { + container.register('template:widget', compile("{{model.name}}")); -test("A control can specify a model to use in its template", function() { - container.register('template:widget', compile("{{model.name}}")); + var controller = container.lookup('controller:parent'); + controller.set('person', { name: "Tom Dale" }); - var controller = container.lookup('controller:parent'); - controller.set('person', { name: "Tom Dale" }); + appendView({ + controller: controller, + template: compile("{{control 'widget' person}}") + }); - appendView({ - controller: controller, - template: compile("{{control 'widget' person}}") + renderedText("Tom Dale"); }); - renderedText("Tom Dale"); -}); + test("A control can be used multiple times", function() { + container.register('template:widget', compile("{{model.name}}")); -test("A control can be used multiple times", function() { - container.register('template:widget', compile("{{model.name}}")); + var controller = container.lookup('controller:parent'); + controller.set('person1', { name: "Tom Dale" }); + controller.set('person2', { name: "Peter Wagenet" }); - var controller = container.lookup('controller:parent'); - controller.set('person1', { name: "Tom Dale" }); - controller.set('person2', { name: "Peter Wagenet" }); + appendView({ + controller: controller, + template: compile("{{control 'widget' person1}}{{control 'widget' person2}}") + }); - appendView({ - controller: controller, - template: compile("{{control 'widget' person1}}{{control 'widget' person2}}") + renderedText("Tom DalePeter Wagenet"); }); - renderedText("Tom DalePeter Wagenet"); -}); + test("A control's state is persisted if the view is destroyed and re-rendered", function() { + container.register('template:widget', compile("{{randomValue}}{{model.name}}")); -test("A control's state is persisted if the view is destroyed and re-rendered", function() { - container.register('template:widget', compile("{{randomValue}}{{model.name}}")); + var controller = container.lookup('controller:parent'); + controller.set('person1', { name: "Tom Dale" }); + controller.set('person2', { name: "Peter Wagenet" }); - var controller = container.lookup('controller:parent'); - controller.set('person1', { name: "Tom Dale" }); - controller.set('person2', { name: "Peter Wagenet" }); + container.register('controller:widget', Ember.Controller.extend({ + randomValue: Ember.computed(function() { + return Math.random() + '' + (+new Date()); + }) + })); - container.register('controller:widget', Ember.Controller.extend({ - randomValue: Ember.computed(function() { - return Math.random() + '' + (+new Date()); - }) - })); + var template = compile("{{control 'widget' person1}}{{control 'widget' person2}}"); - var template = compile("{{control 'widget' person1}}{{control 'widget' person2}}"); + appendView({ + controller: controller, + template: template + }); - appendView({ - controller: controller, - template: template - }); + var text = view.$().text(); + ok(text.match(/^.*Tom Dale.*Peter Wagenet.*$/), "The view rendered"); - var text = view.$().text(); - ok(text.match(/^.*Tom Dale.*Peter Wagenet.*$/), "The view rendered"); + destroy(view); - destroy(view); + appendView({ + controller: controller, + template: template + }); - appendView({ - controller: controller, - template: template + equal(view.$().text(), text); }); - equal(view.$().text(), text); -}); + test("if a controller's model changes, its child controllers are destroyed", function() { + container.register('template:widget', compile("{{randomValue}}{{model.name}}")); -test("if a controller's model changes, its child controllers are destroyed", function() { - container.register('template:widget', compile("{{randomValue}}{{model.name}}")); + var controller = container.lookup('controller:parent'); + controller.set('model', { name: "Tom Dale" }); - var controller = container.lookup('controller:parent'); - controller.set('model', { name: "Tom Dale" }); + container.register('controller:widget', Ember.Controller.extend({ + randomValue: Ember.computed(function() { + return Math.random() + '' + (+new Date()); + }) + })); - container.register('controller:widget', Ember.Controller.extend({ - randomValue: Ember.computed(function() { - return Math.random() + '' + (+new Date()); - }) - })); + appendView({ + controller: controller, + template: compile("{{control 'widget' model}}") + }); - appendView({ - controller: controller, - template: compile("{{control 'widget' model}}") - }); + var childController = view.get('childViews').objectAt(0).get('controller'); - var childController = view.get('childViews').objectAt(0).get('controller'); + ok(view.$().text().match(/^.*Tom Dale.*$/), "The view rendered"); + deepEqual(childController.get('model'), { name: "Tom Dale" }); - ok(view.$().text().match(/^.*Tom Dale.*$/), "The view rendered"); - deepEqual(childController.get('model'), { name: "Tom Dale" }); + Ember.run(function() { + controller.set('model', { name: "Yehuda Katz" }); + }); - Ember.run(function() { - controller.set('model', { name: "Yehuda Katz" }); + equal(childController.isDestroying, true); + ok(view.$().text().match(/^.*Yehuda Katz.*$/), "The view rendered"); }); - equal(childController.isDestroying, true); - ok(view.$().text().match(/^.*Yehuda Katz.*$/), "The view rendered"); -}); - -test("A control should correctly remove model observers", function() { - var Controller = Ember.Controller.extend({ - message: 'bro' - }); + test("A control should correctly remove model observers", function() { + var Controller = Ember.Controller.extend({ + message: 'bro' + }); - container.register('template:widget', compile("{{content}}")); - container.register('controller:bro', Controller); + container.register('template:widget', compile("{{content}}")); + container.register('controller:bro', Controller); - appendView({ - controller: container.lookup('controller:bro'), - template: compile("{{control widget message}}") - }); + appendView({ + controller: container.lookup('controller:bro'), + template: compile("{{control widget message}}") + }); - renderedText("bro"); + renderedText("bro"); - Ember.run(function() { - view.destroy(); - }); + Ember.run(function() { + view.destroy(); + }); - Ember.run(function() { - Ember.set(container.lookup('controller:bro'), 'message', 'grammer'); + Ember.run(function() { + Ember.set(container.lookup('controller:bro'), 'message', 'grammer'); + }); }); -}); +}
true
Other
emberjs
ember.js
8e13610d210cb024894656cce57e06a48ed96944.json
Hide {{control}} behind a flag - Fixes #2073
tests/ember_configuration.js
@@ -28,6 +28,8 @@ ENV['STUB_OBJECT_CREATE'] = !Object.create; } + ENV['EXPERIMENTAL_CONTROL_HELPER'] = true; + EmberDev.distros = { spade: 'ember-spade.js', build: 'ember.js',
true
Other
emberjs
ember.js
f0600f0ba9f2e375a997f2a655b01bbaffb48236.json
Allow 0 as the value of a tag This was broken by a refactor to the render buffer: 079630b
packages/ember-views/lib/system/render_buffer.js
@@ -352,7 +352,7 @@ Ember._RenderBuffer.prototype = for (prop in props) { if (props.hasOwnProperty(prop)) { var value = props[prop]; - if (value) { + if (value || typeof(value) === 'number') { if (value === true) { buffer.push(' ' + prop + '="' + prop + '"'); } else {
true
Other
emberjs
ember.js
f0600f0ba9f2e375a997f2a655b01bbaffb48236.json
Allow 0 as the value of a tag This was broken by a refactor to the render buffer: 079630b
packages/ember-views/tests/system/render_buffer_test.js
@@ -15,6 +15,26 @@ test("RenderBuffers combine strings", function() { equal("<div>ab</div>", buffer.string(), "Multiple pushes should concatenate"); }); +test("value of 0 is included in output", function() { + var buffer, $el; + + buffer = new Ember.RenderBuffer('input'); + buffer.prop('value', 0); + buffer.pushOpeningTag(); + $el = buffer.element(); + + strictEqual($el.value, '0', "generated element has value of '0'"); + + buffer = new Ember.RenderBuffer('input'); + buffer.prop('value', 0); + buffer.push('<div>'); + buffer.pushOpeningTag(); + buffer.push('</div>'); + $el = Ember.$(buffer.innerString()); + + strictEqual($el.find('input').val(), '0', "raw tag has value of '0'"); +}); + test("prevents XSS injection via `id`", function() { var buffer = new Ember.RenderBuffer('div');
true
Other
emberjs
ember.js
aab99e5f036957e90e46dfce76282d93132f4a72.json
Add failing test for #2050
packages/ember-runtime/tests/controllers/array_controller_test.js
@@ -21,3 +21,8 @@ Ember.MutableArrayTests.extend({ return obj.toArray ? obj.toArray() : obj.slice(); } }).run(); + +test("defaults it's `content` to an empty array", function () { + var Controller = Ember.ArrayController.extend(); + equal(Controller.create().get("content"), [], "`ArrayController` defaults it's content to an empty array"); +});
false
Other
emberjs
ember.js
e644762e3eef776409692e0c0ec1ddb260633d4c.json
Add download links for VirtualBox and Vagrant
CONTRIBUTING.md
@@ -64,21 +64,21 @@ then that will speed the process along. The stack needed to build emberjs can be quite complex to setup for new developers. A VagrantFile is here to ease things for newcomers. Using Vagrant to buid latest version of Ember.js is quite simple. Just follow nexts 4 steps: -1. Install Vagrant -2. Retrieve chef cookbooks +1. Install Virtual Box - [Download](https://www.virtualbox.org/wiki/Downloads) +2. Install Vagrant - [Download](http://downloads.vagrantup.com/) + +3. Retrieve chef cookbooks ~~~ git submodule init git submodule update ~~~ -3. Lauch your vagrant virtual machine - +4. Lauch your vagrant virtual machine ~~~ vagrant up vagrant ssh ~~~ -4. Use it! - +5. Use it! ~~~ cd /vagrant bundle install
false
Other
emberjs
ember.js
9758b1e1635be19ccd577de9557f3016f69fe1f3.json
Fix false redirect alarm in Router.didTransition In some cases didTransition believed a redirect had occurred when this was not the case. This in turn prevented currentPath from being set among other issues.
packages/ember-routing/lib/system/route.js
@@ -40,7 +40,7 @@ Ember.Route = Ember.Object.extend({ @param {...Object} models the */ transitionTo: function() { - this.transitioned = true; + if (this._checkingRedirect) { this.redirected = true; } return this.router.transitionTo.apply(this.router, arguments); }, @@ -53,7 +53,7 @@ Ember.Route = Ember.Object.extend({ @param {...Object} models the */ replaceWith: function() { - this.transitioned = true; + if (this._checkingRedirect) { this.redirected = true; } return this.router.replaceWith.apply(this.router, arguments); }, @@ -69,10 +69,13 @@ Ember.Route = Ember.Object.extend({ @method setup */ setup: function(context) { - this.transitioned = false; + this.redirected = false; + this._checkingRedirect = true; + this.redirect(context); - if (this.transitioned) { return false; } + this._checkingRedirect = false; + if (this.redirected) { return false; } var controller = this.controllerFor(this.routeName, context);
true
Other
emberjs
ember.js
9758b1e1635be19ccd577de9557f3016f69fe1f3.json
Fix false redirect alarm in Router.didTransition In some cases didTransition believed a redirect had occurred when this was not the case. This in turn prevented currentPath from being set among other issues.
packages/ember-routing/lib/system/router.js
@@ -69,7 +69,7 @@ Ember.Router = Ember.Object.extend({ didTransition: function(infos) { // Don't do any further action here if we redirected for (var i=0, l=infos.length; i<l; i++) { - if (infos[i].handler.transitioned) { return; } + if (infos[i].handler.redirected) { return; } } var appController = this.container.lookup('controller:application'),
true
Other
emberjs
ember.js
9758b1e1635be19ccd577de9557f3016f69fe1f3.json
Fix false redirect alarm in Router.didTransition In some cases didTransition believed a redirect had occurred when this was not the case. This in turn prevented currentPath from being set among other issues.
packages/ember/tests/routing/basic_test.js
@@ -1172,6 +1172,42 @@ test("Redirecting from the middle of a route aborts the remainder of the routes" equal(router.get('location').getURL(), "/home"); }); +test("Transitioning from a parent event does not prevent currentPath from being set", function() { + Router.map(function() { + this.resource("foo", function() { + this.resource("bar", function() { + this.route("baz"); + }); + this.route("qux"); + }); + }); + + App.FooRoute = Ember.Route.extend({ + events: { + goToQux: function() { + this.transitionTo('foo.qux'); + } + } + }); + + bootApplication(); + + var applicationController = router.container.lookup('controller:application'); + + Ember.run(function() { + router.handleURL("/foo/bar/baz"); + }); + + equal(applicationController.get('currentPath'), 'foo.bar.baz'); + + Ember.run(function() { + router.send("goToQux"); + }); + + equal(applicationController.get('currentPath'), 'foo.qux'); + equal(router.get('location').getURL(), "/foo/qux"); +}); + test("Generated names can be customized when providing routes with dot notation", function() { expect(3);
true
Other
emberjs
ember.js
3df5ddfd4f01555da31a18d6b8d2fbbf82b11ea3.json
Tack the raw function onto bound helpers
packages/ember-handlebars/lib/ext.js
@@ -246,7 +246,7 @@ Ember.Handlebars.registerHelper('helperMissing', function(path, options) { Ember.Handlebars.registerBoundHelper = function(name, fn) { var dependentKeys = slice.call(arguments, 2); - Ember.Handlebars.registerHelper(name, function() { + function helper() { var properties = slice.call(arguments, 0, -1), numProperties = properties.length, options = arguments[arguments.length - 1], @@ -308,7 +308,10 @@ Ember.Handlebars.registerBoundHelper = function(name, fn) { for (var i=0, l=dependentKeys.length; i<l; i++) { view.registerObserver(pathRoot, path + '.' + dependentKeys[i], bindView, rerenderBoundHelperView); } - }); + } + + helper._rawFunction = fn; + Ember.Handlebars.registerHelper(name, helper); }; /**
false
Other
emberjs
ember.js
03cebf38d091604046b0f7704804fe54630bdab9.json
Wrap the hashchange event in an Ember.run
packages/ember-routing/lib/location/hash_location.js
@@ -61,12 +61,14 @@ Ember.HashLocation = Ember.Object.extend({ var guid = Ember.guidFor(this); Ember.$(window).bind('hashchange.ember-location-'+guid, function() { - var path = location.hash.substr(1); - if (get(self, 'lastSetURL') === path) { return; } + Ember.run(function() { + var path = location.hash.substr(1); + if (get(self, 'lastSetURL') === path) { return; } - set(self, 'lastSetURL', null); + set(self, 'lastSetURL', null); - callback(location.hash.substr(1)); + callback(location.hash.substr(1)); + }); }); },
false
Other
emberjs
ember.js
3ff578ca023a8c25f22a62dfbd870d171740cf13.json
Test the URL for app reset
packages/ember-application/tests/system/reset_test.js
@@ -64,7 +64,7 @@ test("When an application is reset, the ApplicationView is torn down", function( }); test("When an application is reset, the router URL is reset to `/`", function() { - var location; + var location, router; Ember.run(function() { application = Application.create(); @@ -78,7 +78,7 @@ test("When an application is reset, the router URL is reset to `/`", function() }); }); - var router = application.__container__.lookup('router:main'); + router = application.__container__.lookup('router:main'); location = router.get('location'); location.handleURL('/one'); @@ -88,6 +88,10 @@ test("When an application is reset, the router URL is reset to `/`", function() }); var applicationController = application.__container__.lookup('controller:application'); + router = application.__container__.lookup('router:main'); + location = router.get('location'); + + equal(location.getURL(), ''); equal(get(applicationController, 'currentPath'), "index");
false
Other
emberjs
ember.js
eb0fa874223641e8905077f2ab89e1676cea5117.json
Fix handling of keywords in bind helpers Fixes #1315
packages/ember-handlebars/lib/helpers/binding.js
@@ -21,22 +21,18 @@ function bind(property, options, preserveContext, shouldDisplay, valueNormalizer inverse = options.inverse, view = data.view, currentContext = this, - pathRoot, path, normalized, - observer, i; + normalized, observer, i; normalized = normalizePath(currentContext, property, data); - pathRoot = normalized.root; - path = normalized.path; - // Set up observers for observable objects if ('object' === typeof this) { if (data.insideGroup) { observer = function() { Ember.run.once(view, 'rerender'); }; - var template, context, result = handlebarsGet(pathRoot, path, options); + var template, context, result = handlebarsGet(currentContext, property, options); result = valueNormalizer(result); @@ -58,8 +54,8 @@ function bind(property, options, preserveContext, shouldDisplay, valueNormalizer valueNormalizerFunc: valueNormalizer, displayTemplate: fn, inverseTemplate: inverse, - path: path, - pathRoot: pathRoot, + path: property, + pathRoot: currentContext, previousContext: currentContext, isEscaped: !options.hash.unescaped, templateData: options.data @@ -76,46 +72,42 @@ function bind(property, options, preserveContext, shouldDisplay, valueNormalizer // tells the Ember._HandlebarsBoundView to re-render. If property // is an empty string, we are printing the current context // object ({{this}}) so updating it is not our responsibility. - if (path !== '') { - view.registerObserver(pathRoot, path, observer); + if (normalized.path !== '') { + view.registerObserver(normalized.root, normalized.path, observer); if (childProperties) { for (i=0; i<childProperties.length; i++) { - view.registerObserver(pathRoot, path+'.'+childProperties[i], observer); + view.registerObserver(normalized.root, normalized.path+'.'+childProperties[i], observer); } } } } else { // The object is not observable, so just render it out and // be done with it. - data.buffer.push(handlebarsGet(pathRoot, path, options)); + data.buffer.push(handlebarsGet(currentContext, property, options)); } } function simpleBind(property, options) { var data = options.data, view = data.view, currentContext = this, - pathRoot, path, normalized, - observer; + normalized, observer; normalized = normalizePath(currentContext, property, data); - pathRoot = normalized.root; - path = normalized.path; - // Set up observers for observable objects if ('object' === typeof this) { if (data.insideGroup) { observer = function() { Ember.run.once(view, 'rerender'); }; - var result = handlebarsGet(pathRoot, path, options); + var result = handlebarsGet(currentContext, property, options); if (result === null || result === undefined) { result = ""; } data.buffer.push(result); } else { var bindView = new Ember._SimpleHandlebarsView( - path, pathRoot, !options.hash.unescaped, options.data + property, currentContext, !options.hash.unescaped, options.data ); bindView._parentView = view; @@ -130,13 +122,13 @@ function simpleBind(property, options) { // tells the Ember._HandlebarsBoundView to re-render. If property // is an empty string, we are printing the current context // object ({{this}}) so updating it is not our responsibility. - if (path !== '') { - view.registerObserver(pathRoot, path, observer); + if (normalized.path !== '') { + view.registerObserver(normalized.root, normalized.path, observer); } } else { // The object is not observable, so just render it out and // be done with it. - data.buffer.push(handlebarsGet(pathRoot, path, options)); + data.buffer.push(handlebarsGet(currentContext, property, options)); } } @@ -472,24 +464,21 @@ EmberHandlebars.registerHelper('bindAttr', function(options) { // current value of the property as an attribute. forEach.call(attrKeys, function(attr) { var path = attrs[attr], - pathRoot, normalized; + normalized; Ember.assert(fmt("You must provide a String for a bound attribute, not %@", [path]), typeof path === 'string'); normalized = normalizePath(ctx, path, options.data); - pathRoot = normalized.root; - path = normalized.path; - - var value = (path === 'this') ? pathRoot : handlebarsGet(pathRoot, path, options), + var value = (path === 'this') ? normalized.root : handlebarsGet(ctx, path, options), type = Ember.typeOf(value); Ember.assert(fmt("Attributes must be numbers, strings or booleans, not %@", [value]), value === null || value === undefined || type === 'number' || type === 'string' || type === 'boolean'); var observer, invoker; observer = function observer() { - var result = handlebarsGet(pathRoot, path, options); + var result = handlebarsGet(ctx, path, options); Ember.assert(fmt("Attributes must be numbers, strings or booleans, not %@", [result]), result === null || result === undefined || typeof result === 'number' || typeof result === 'string' || typeof result === 'boolean'); @@ -500,7 +489,7 @@ EmberHandlebars.registerHelper('bindAttr', function(options) { // In that case, we can assume the template has been re-rendered // and we need to clean up the observer. if (!elem || elem.length === 0) { - Ember.removeObserver(pathRoot, path, invoker); + Ember.removeObserver(normalized.root, normalized.path, invoker); return; } @@ -515,7 +504,7 @@ EmberHandlebars.registerHelper('bindAttr', function(options) { // When the observer fires, find the element using the // unique data id and update the attribute to the new value. if (path !== 'this') { - view.registerObserver(pathRoot, path, invoker); + view.registerObserver(normalized.root, normalized.path, invoker); } // if this changes, also change the logic in ember-views/lib/views/view.js @@ -605,7 +594,7 @@ EmberHandlebars.bindClasses = function(context, classBindings, view, bindAttrId, // class name. observer = function() { // Get the current value of the property - newClass = classStringForPath(pathRoot, parsedPath, options); + newClass = classStringForPath(context, parsedPath, options); elem = bindAttrId ? view.$("[data-bindattr-" + bindAttrId + "='" + bindAttrId + "']") : view.$(); // If we can't find the element anymore, a parent template has been @@ -639,7 +628,7 @@ EmberHandlebars.bindClasses = function(context, classBindings, view, bindAttrId, // We've already setup the observer; now we just need to figure out the // correct behavior right now on the first pass through. - value = classStringForPath(pathRoot, parsedPath, options); + value = classStringForPath(context, parsedPath, options); if (value) { ret.push(value);
true
Other
emberjs
ember.js
eb0fa874223641e8905077f2ab89e1676cea5117.json
Fix handling of keywords in bind helpers Fixes #1315
packages/ember-handlebars/tests/handlebars_test.js
@@ -354,6 +354,27 @@ test("Ember.View should update when a property changes and the bind helper is us equal(view.$('#first').text(), "bazam", "view updates when a bound property changes"); }); +test("Ember.View should not use keyword incorrectly - Issue #1315", function() { + container.register('template', 'foo', Ember.Handlebars.compile('{{#each value in view.content}}{{value}}-{{#each option in view.options}}{{option.value}}:{{option.label}} {{/each}}{{/each}}')); + + view = Ember.View.create({ + container: container, + templateName: 'foo', + + content: Ember.A(['X', 'Y']), + options: Ember.A([ + { label: 'One', value: 1 }, + { label: 'Two', value: 2 } + ]) + }); + + Ember.run(function() { + view.appendTo('#qunit-fixture'); + }); + + equal(view.$().text(), 'X-1:One 2:Two Y-1:One 2:Two '); +}); + test("Ember.View should update when a property changes and no bind helper is used", function() { container.register('template', 'foo', Ember.Handlebars.compile('<h1 id="first">{{#with view.content}}{{wham}}{{/with}}</h1>'));
true
Other
emberjs
ember.js
737c2872ef21f973dd265031764631515d6ed716.json
Fix typo in evented mixin.
packages/ember-runtime/lib/mixins/evented.js
@@ -83,7 +83,7 @@ Ember.Evented = Ember.Mixin.create({ event. ```javascript - person.on('didEat', food) { + person.on('didEat', function(food) { console.log('person ate some ' + food); });
false
Other
emberjs
ember.js
e142d7f522d4cfbf443102d0147da5cd41d4e957.json
Update documentation on router logging
packages/ember-application/lib/system/application.js
@@ -114,7 +114,14 @@ var get = Ember.get, set = Ember.set, ### Routing In addition to creating your application's router, `Ember.Application` is - also responsible for telling the router when to start routing. + also responsible for telling the router when to start routing. Transitions + between routes can be logged with the LOG_TRANSITIONS flag: + + ```javascript + window.App = Ember.Application.create({ + LOG_TRANSITIONS: true + }); + ``` By default, the router will begin trying to translate the current URL into application state once the browser emits the `DOMContentReady` event. If you @@ -123,14 +130,7 @@ var get = Ember.get, set = Ember.set, If there is any setup required before routing begins, you can implement a `ready()` method on your app that will be invoked immediately before routing - begins: - - ```javascript - window.App = Ember.Application.create({ - ready: function() { - this.set('router.enableLogging', true); - } - }); + begins. To begin routing, you must have at a minimum a top-level controller and view. You define these as `App.ApplicationController` and `App.ApplicationView`,
false
Other
emberjs
ember.js
5ee0487184539babef74afa92f20e8a11c3f80e5.json
Fix failing test written in 9d3ecef - Fixes #1982
packages/ember-runtime/lib/controllers/array_controller.js
@@ -136,20 +136,22 @@ Ember.ArrayController = Ember.ArrayProxy.extend(Ember.ControllerMixin, objectAtContent: function(idx) { var length = get(this, 'length'), - object = get(this,'arrangedContent').objectAt(idx), - controllerClass = this.lookupItemController(object); - - if (controllerClass && idx < length) { - return this.controllerAt(idx, object, controllerClass); - } else { - // When controllerClass is falsy we have not opted in to using item - // controllers, so return the object directly. However, when - // controllerClass is defined but the index is out of range, we want to - // return the "out of range" value, whatever that might be. Rather than - // make assumptions (e.g. guessing `null` or `undefined`) we defer this to - // `arrangedContent`. - return object; + object = get(this,'arrangedContent').objectAt(idx); + + if (idx < length) { + var controllerClass = this.lookupItemController(object); + if (controllerClass) { + return this.controllerAt(idx, object, controllerClass); + } } + + // When `controllerClass` is falsy, we have not opted in to using item + // controllers, so return the object directly. + + // When the index is out of range, we want to return the "out of range" + // value, whatever that might be. Rather than make assumptions + // (e.g. guessing `null` or `undefined`) we defer this to `arrangedContent`. + return object; }, arrangedContentDidChange: function() {
false
Other
emberjs
ember.js
6b11eeb9ca71f110c3881050c41eaa039347f0eb.json
Allow 0 as the value of a tag
packages/ember-views/lib/system/render_buffer.js
@@ -331,7 +331,7 @@ Ember._RenderBuffer.prototype = this.elementAttributes = null; } - if (value) { + if (value || typeof value === 'number') { buffer.push(' value="' + this._escapeAttribute(value) + '"'); this.elementValue = null; @@ -391,7 +391,7 @@ Ember._RenderBuffer.prototype = this.elementAttributes = null; } - if (value) { + if (value || typeof value === 'number') { $element.val(value); this.elementValue = null;
true
Other
emberjs
ember.js
6b11eeb9ca71f110c3881050c41eaa039347f0eb.json
Allow 0 as the value of a tag
packages/ember-views/tests/system/render_buffer_test.js
@@ -17,6 +17,26 @@ test("RenderBuffers combine strings", function() { equal("<div>ab</div>", cleanedString, "Multiple pushes should concatenate"); }); +test("value of 0 is included in output", function() { + var buffer, $el; + + buffer = new Ember.RenderBuffer('input'); + buffer.val(0); + buffer.pushOpeningTag(); + $el = buffer.element(); + + strictEqual($el.value, '0', "generated element has value of '0'"); + + buffer = new Ember.RenderBuffer('input'); + buffer.val(0); + buffer.push('<div>'); + buffer.pushOpeningTag(); + buffer.push('</div>'); + $el = Ember.$(buffer.innerString()); + + strictEqual($el.find('input').val(), '0', "raw tag has value of '0'"); +}); + test("prevents XSS injection via `id`", function() { var buffer = new Ember.RenderBuffer('div');
true
Other
emberjs
ember.js
0f740430c0fcfdeb41d9c7e5bb412651db688b18.json
Add start of {{render}} documentation
packages/ember-routing/lib/helpers/render.js
@@ -9,6 +9,23 @@ require('ember-handlebars/helpers/view'); Ember.onLoad('Ember.Handlebars', function(Handlebars) { + /** + Renders the named template in the current context using the singleton + instance of the same-named controller. + + If a view class with the same name exists, uses the view class. + + If a `model` is specified, it becomes the model for that controller. + + The default target for `{{action}}`s in the rendered template is the + named controller. + + @method action + @for Ember.Handlebars.helpers + @param {String} actionName + @param {Object?} model + @param {Hash} options + */ Ember.Handlebars.registerHelper('render', function(name, contextString, options) { Ember.assert("You must pass a template to render", arguments.length >= 2); var container, router, controller, view, context;
false
Other
emberjs
ember.js
e7ea6a3d0d2c1f74c0dbe8f75430ec04cecb8a49.json
Create activate and deactivate hooks for router
packages/ember-routing/lib/system/route.js
@@ -10,9 +10,26 @@ var get = Ember.get, set = Ember.set, Ember.Route = Ember.Object.extend({ exit: function() { + this.deactivate(); teardownView(this); }, + enter: function() { + this.activate(); + }, + + /** + This hook is executed when the router completely exits this route. It is + not executed when the model for the route changes. + */ + deactivate: Ember.K, + + /** + This hook is executed when the router enters the route for the first time. + It is not executed when the model for the route changes. + */ + activate: Ember.K, + /** Transition into another route. Optionally supply a model for the route in question. The model will be serialized into the URL
false
Other
emberjs
ember.js
a089eb4ffdacd617fcd613068f7a354379a9c874.json
Add rake task for building pull requests
Gemfile
@@ -9,4 +9,5 @@ gem "uglifier", :git => "https://github.com/lautis/uglifier.git" group :development do gem "rack" gem "kicker" + gem "grit" end
true
Other
emberjs
ember.js
a089eb4ffdacd617fcd613068f7a354379a9c874.json
Add rake task for building pull requests
Gemfile.lock
@@ -26,24 +26,40 @@ GIT GEM remote: http://rubygems.org/ specs: + coderay (1.0.8) colored (1.2) + diff-lcs (1.2.0) execjs (1.4.0) multi_json (~> 1.0) + grit (2.5.0) + diff-lcs (~> 1.1) + mime-types (~> 1.15) + posix-spawn (~> 0.3.6) json (1.7.6) kicker (2.6.1) listen listen (0.6.0) + method_source (0.8.1) + mime-types (1.19) multi_json (1.3.7) + posix-spawn (0.3.6) + pry (0.9.10) + coderay (~> 1.0.5) + method_source (~> 0.8) + slop (~> 3.3.1) rack (1.4.1) rake (0.9.6) + slop (3.3.3) thor (0.16.0) PLATFORMS ruby DEPENDENCIES colored + grit kicker + pry rack rake-pipeline! rake-pipeline-web-filters!
true
Other
emberjs
ember.js
a089eb4ffdacd617fcd613068f7a354379a9c874.json
Add rake task for building pull requests
Rakefile
@@ -481,3 +481,31 @@ namespace :release do end task :default => :test + + +desc "Build Ember.js from a given fork & branch" +task :build, :username, :branch do |t, args| + require "grit" + + if args.to_hash.keys.length != 2 + puts "Usage: rake build[wycats,some-cool-feature]" + exit 1 + end + + username, branch = args[:username], args[:branch] + + remote_path = "https://github.com/#{username}/ember.js.git" + + repo = Grit::Repo.new(File.dirname(File.expand_path(__FILE__))) + + unless repo.remotes.map(&:name).grep(/#{username}/).length == 0 + repo.remote_add(username, remote_path) + end + + repo.remote_fetch username + + `git checkout -B testing-#{username}-#{branch} master` + `git merge #{username}/#{branch}` + + puts "Resolve possible merge conflicts and run `rake dist`" +end
true
Other
emberjs
ember.js
04df12c25fe3c9afb21b5e055e74d58ce3339f2f.json
Prevent overwrite on view registration See #1553
packages/ember-views/lib/views/view.js
@@ -58,7 +58,10 @@ Ember.CoreView = Ember.Object.extend(Ember.Evented, { // Register the view for event handling. This hash is used by // Ember.EventDispatcher to dispatch incoming events. - if (!this.isVirtual) Ember.View.views[this.elementId] = this; + if (!this.isVirtual) { + Ember.assert("Attempted to register a view with an id already in use: "+this.elementId, !Ember.View.views[this.elementId]); + Ember.View.views[this.elementId] = this; + } this.addBeforeObserver('elementId', function() { throw new Error("Changing a view's elementId after creation is not allowed");
false
Other
emberjs
ember.js
8c6064902d1221cc83b5fe5e1f391cf81d46fa48.json
CollectionView cleans up emptyView - Fixes #1957 Previously, if emptyView was a class, CollectionView would create an instance but never destroy it.
packages/ember-views/lib/views/collection_view.js
@@ -241,6 +241,10 @@ Ember.CollectionView = Ember.ContainerView.extend( if (content) { content.removeArrayObserver(this); } this._super(); + + if (this._createdEmptyView) { + this._createdEmptyView.destroy(); + } }, arrayWillChange: function(content, start, removedCount) { @@ -310,9 +314,13 @@ Ember.CollectionView = Ember.ContainerView.extend( var emptyView = get(this, 'emptyView'); if (!emptyView) { return; } + var isClass = Ember.CoreView.detect(emptyView); + emptyView = this.createChildView(emptyView); addedViews.push(emptyView); set(this, 'emptyView', emptyView); + + if (isClass) { this._createdEmptyView = emptyView; } } this.replace(start, 0, addedViews); },
false
Other
emberjs
ember.js
96b56b147152e3e8eccc2b6591c278c6854e7b38.json
Remove old ember_ debug methods
.jshintrc
@@ -7,10 +7,6 @@ "Handlebars", "Metamorph", "RSVP", - "ember_assert", - "ember_warn", - "ember_deprecate", - "ember_deprecateFunc", "require", "requireModule", "equal",
true
Other
emberjs
ember.js
96b56b147152e3e8eccc2b6591c278c6854e7b38.json
Remove old ember_ debug methods
packages/ember-debug/lib/main.js
@@ -142,10 +142,3 @@ Ember.deprecateFunc = function(message, func) { return func.apply(this, arguments); }; }; - -if ('undefined' !== typeof window) { - window.ember_assert = Ember.deprecateFunc("ember_assert is deprecated. Please use Ember.assert instead.", Ember.assert); - window.ember_warn = Ember.deprecateFunc("ember_warn is deprecated. Please use Ember.warn instead.", Ember.warn); - window.ember_deprecate = Ember.deprecateFunc("ember_deprecate is deprecated. Please use Ember.deprecate instead.", Ember.deprecate); - window.ember_deprecateFunc = Ember.deprecateFunc("ember_deprecateFunc is deprecated. Please use Ember.deprecateFunc instead.", Ember.deprecateFunc); -}
true
Other
emberjs
ember.js
96b56b147152e3e8eccc2b6591c278c6854e7b38.json
Remove old ember_ debug methods
packages/ember-metal/lib/core.js
@@ -128,15 +128,6 @@ if ('undefined' === typeof Ember.deprecateFunc) { Ember.deprecateFunc = function(_, func) { return func; }; } -// These are deprecated but still supported - -if ('undefined' === typeof ember_assert) { exports.ember_assert = Ember.K; } -if ('undefined' === typeof ember_warn) { exports.ember_warn = Ember.K; } -if ('undefined' === typeof ember_deprecate) { exports.ember_deprecate = Ember.K; } -if ('undefined' === typeof ember_deprecateFunc) { - exports.ember_deprecateFunc = function(_, func) { return func; }; -} - /** Previously we used `Ember.$.uuid`, however `$.uuid` has been removed from jQuery master. We'll just bootstrap our own uuid now.
true
Other
emberjs
ember.js
fae401b9a681ee126336199cd874dbabbad76923.json
remove traces of eachHelper
packages/ember-handlebars/lib/helpers/collection.js
@@ -201,7 +201,6 @@ Ember.Handlebars.registerHelper('collection', function(path, options) { hash.emptyView = emptyViewClass; itemHash._context = Ember.computed.alias('content'); - delete hash.eachHelper; var viewString = view.toString();
true
Other
emberjs
ember.js
fae401b9a681ee126336199cd874dbabbad76923.json
remove traces of eachHelper
packages/ember-handlebars/lib/helpers/each.js
@@ -273,8 +273,6 @@ Ember.Handlebars.registerHelper('each', function(path, options) { if (path === '') { path = "this"; } options.hash.keyword = keywordName; - } else { - options.hash.eachHelper = 'each'; } options.hash.dataSourceBinding = path;
true
Other
emberjs
ember.js
2f5adaa7a2ed502932e33dc441d613098c6af79a.json
Render values with val. Fixes #1828 In jQuery 1.9, setting the value of an input with `attr(` is no longer supported. Here we explode `applyAttributeBindings` to handle value properties with `val(` instead. of `attr(`. This required adding an duck of value handling in jQuery to `RenderBuffer`
packages/ember-handlebars/tests/controls/text_field_test.js
@@ -141,6 +141,35 @@ test("value binding works properly for inputs that haven't been created", functi equal(textField.$().val(), 'ohai', "value is reflected in the input element once it is created"); }); +test("value binding sets value on the element", function() { + Ember.run(function() { + textField = Ember.TextField.createWithMixins({ + valueBinding: 'TestObject.value' + }); + textField.append(); + }); + + // Set the value via the DOM + Ember.run(function() { + textField.$().val('via dom'); + // Trigger lets the view know we changed this value (like a real user editing) + textField.trigger('input', Ember.Object.create({ + type: 'input' + })); + }); + + equal(get(textField, 'value'), 'via dom', "value property was properly updated via dom"); + equal(textField.$().val(), 'via dom', "dom property was properly updated via dom"); + + // Now, set it via the binding + Ember.run(function() { + set(TestObject, 'value', 'via view'); + }); + + equal(get(textField, 'value'), 'via view', "value property was properly updated via view"); + equal(textField.$().val(), 'via view', "dom property was properly updated via view"); +}); + test("should call the insertNewline method when return key is pressed", function() { var wasCalled; var event = Ember.Object.create({
true
Other
emberjs
ember.js
2f5adaa7a2ed502932e33dc441d613098c6af79a.json
Render values with val. Fixes #1828 In jQuery 1.9, setting the value of an input with `attr(` is no longer supported. Here we explode `applyAttributeBindings` to handle value properties with `val(` instead. of `attr(`. This required adding an duck of value handling in jQuery to `RenderBuffer`
packages/ember-views/lib/system/render_buffer.js
@@ -104,6 +104,19 @@ Ember._RenderBuffer.prototype = */ elementAttributes: null, + /** + The value for this attribute. Values cannot be set via attr after + jQuery 1.9, they need to be set with val() instead. + + You should not maintain this value yourself, rather, you should use + the `val()` method of `Ember.RenderBuffer`. + + @property elementValue + @type String + @default null + */ + elementValue: null, + /** The tagname of the element an instance of `Ember.RenderBuffer` represents. @@ -212,6 +225,26 @@ Ember._RenderBuffer.prototype = return this; }, + /** + Adds an value which will be rendered to the element. + + @method val + @param {String} value The value to set + @chainable + @return {Ember.RenderBuffer|String} this or the current value + */ + val: function(value) { + var elementValue = this.elementValue; + + if (arguments.length === 0) { + return elementValue; + } else { + this.elementValue = value; + } + + return this; + }, + /** Remove an attribute from the list of attributes to render. @@ -259,6 +292,7 @@ Ember._RenderBuffer.prototype = id = this.elementId, classes = this.classes, attrs = this.elementAttributes, + value = this.elementValue, style = this.elementStyle, prop; @@ -297,6 +331,12 @@ Ember._RenderBuffer.prototype = this.elementAttributes = null; } + if (value) { + buffer.push(' value="' + this._escapeAttribute(value) + '"'); + + this.elementValue = null; + } + buffer.push('>'); }, @@ -316,6 +356,7 @@ Ember._RenderBuffer.prototype = id = this.elementId, classes = this.classes, attrs = this.elementAttributes, + value = this.elementValue, style = this.elementStyle, styleBuffer = '', prop; @@ -350,6 +391,12 @@ Ember._RenderBuffer.prototype = this.elementAttributes = null; } + if (value) { + $element.val(value); + + this.elementValue = null; + } + return element; },
true
Other
emberjs
ember.js
2f5adaa7a2ed502932e33dc441d613098c6af79a.json
Render values with val. Fixes #1828 In jQuery 1.9, setting the value of an input with `attr(` is no longer supported. Here we explode `applyAttributeBindings` to handle value properties with `val(` instead. of `attr(`. This required adding an duck of value handling in jQuery to `RenderBuffer`
packages/ember-views/lib/views/view.js
@@ -2321,17 +2321,57 @@ Ember.View.views = {}; Ember.View.childViewsProperty = childViewsProperty; Ember.View.applyAttributeBindings = function(elem, name, value) { + if (name === 'value') { + Ember.View.applyValueBinding(elem, value); + } else { + Ember.View.applyAttributeBinding(elem, name, value); + } +}; + +Ember.View.applyAttributeBinding = function(elem, name, value) { var type = Ember.typeOf(value); var currentValue = elem.attr(name); // if this changes, also change the logic in ember-handlebars/lib/helpers/binding.js - if ((type === 'string' || (type === 'number' && !isNaN(value))) && value !== currentValue) { + if ( + ( + ( type === 'string' ) || + ( type === 'number' && !isNaN(value) ) || + ( type === 'boolean' && value ) + ) && ( + value !== currentValue + ) + ) { elem.attr(name, value); - } else if (value && type === 'boolean') { - elem.attr(name, name); } else if (!value) { elem.removeAttr(name); } }; +Ember.View.applyValueBinding = function(elem, value) { + var type = Ember.typeOf(value); + var currentValue = elem.val(); + + // if this changes, also change the logic in ember-handlebars/lib/helpers/binding.js + if ( + ( + ( type === 'string' ) || + ( type === 'number' && !isNaN(value) ) || + ( type === 'boolean' && value ) + ) && ( + value !== currentValue + ) + ) { + if (elem.caretPosition) { + var caretPosition = elem.caretPosition(); + elem.val(value); + elem.setCaretPosition(caretPosition); + } else { + elem.val(value); + } + } else if (!value) { + elem.val(''); + } +}; + Ember.View.states = states;
true