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
1fa9fa630fc31a7310fd838c2ee51ac940464a9d.json
Fix EXTEND_PROTOTYPES for sproutcore-runtime
packages/sproutcore-runtime/tests/legacy_1x/system/binding_test.js
@@ -404,7 +404,7 @@ test("toObject.value should be second value if first is falsy", function() { module("Binding with '[]'", { setup: function() { - fromObject = SC.Object.create({ value: [] }); + fromObject = SC.Object.create({ value: SC.NativeArray.apply([]) }); toObject = SC.Object.create({ value: '' }); root = { toObject: toObject, fromObject: fromObject };
true
Other
emberjs
ember.js
1fa9fa630fc31a7310fd838c2ee51ac940464a9d.json
Fix EXTEND_PROTOTYPES for sproutcore-runtime
packages/sproutcore-runtime/tests/legacy_1x/system/object/base_test.js
@@ -151,10 +151,10 @@ test("Checking the detectInstance() function on an object and its subclass", fun }); test("subclasses should contain defined subclasses", function() { - ok(obj.subclasses.contains(obj1), 'obj.subclasses should contain obj1'); + ok(jQuery.inArray(obj1, obj.subclasses) > -1, 'obj.subclasses should contain obj1'); equals(get(obj1.subclasses, 'length'),0,'obj1.subclasses should be empty'); var kls2 = obj1.extend(); - ok(obj1.subclasses.contains(kls2), 'obj1.subclasses should contain kls2'); + ok(jQuery.inArray(kls2, obj1.subclasses) > -1, 'obj1.subclasses should contain kls2'); });
true
Other
emberjs
ember.js
1fa9fa630fc31a7310fd838c2ee51ac940464a9d.json
Fix EXTEND_PROTOTYPES for sproutcore-runtime
packages/sproutcore-runtime/tests/legacy_1x/system/object/concatenated_test.js
@@ -37,7 +37,7 @@ var values = get(obj, 'values'), expected = ['a', 'b', 'c', 'd', 'e', 'f']; - same(values, expected, "should concatenate values property (expected: %@, got: %@)".fmt(expected, values)); + same(values, expected, SC.String.fmt("should concatenate values property (expected: %@, got: %@)", expected, values)); }); test("concatenates subclasses", function() { @@ -48,7 +48,7 @@ var values = get(obj, 'values'), expected = ['a', 'b', 'c', 'd', 'e', 'f']; - same(values, expected, "should concatenate values property (expected: %@, got: %@)".fmt(expected, values)); + same(values, expected, SC.String.fmt("should concatenate values property (expected: %@, got: %@)", expected, values)); }); test("concatenates reopen", function() { @@ -59,7 +59,7 @@ var values = get(obj, 'values'), expected = ['a', 'b', 'c', 'd', 'e', 'f']; - same(values, expected, "should concatenate values property (expected: %@, got: %@)".fmt(expected, values)); + same(values, expected, SC.String.fmt("should concatenate values property (expected: %@, got: %@)", expected, values)); }); test("concatenates mixin", function() { @@ -73,7 +73,7 @@ var values = get(obj, 'values'), expected = ['a', 'b', 'c', 'd', 'e', 'f']; - same(values, expected, "should concatenate values property (expected: %@, got: %@)".fmt(expected, values)); + same(values, expected, SC.String.fmt("should concatenate values property (expected: %@, got: %@)", expected, values)); }); test("concatenates reopen, subclass, and instance", function() { @@ -83,7 +83,7 @@ var values = get(obj, 'values'), expected = ['a', 'b', 'c', 'd', 'e', 'f']; - same(values, expected, "should concatenate values property (expected: %@, got: %@)".fmt(expected, values)); + same(values, expected, SC.String.fmt("should concatenate values property (expected: %@, got: %@)", expected, values)); });
true
Other
emberjs
ember.js
1fa9fa630fc31a7310fd838c2ee51ac940464a9d.json
Fix EXTEND_PROTOTYPES for sproutcore-runtime
packages/sproutcore-runtime/tests/legacy_1x/system/set_test.js
@@ -41,7 +41,7 @@ test("SC.Set.create() should create empty set", function() { }); test("SC.Set.create([1,2,3]) should create set with three items in them", function() { - var set = SC.Set.create([a,b,c]) ; + var set = SC.Set.create(SC.NativeArray.apply([a,b,c])) ; equals(set.length, 3) ; equals(set.contains(a), YES) ; equals(set.contains(b), YES) ; @@ -174,11 +174,11 @@ module("SC.Set.remove + SC.Set.contains", { // generate a set with every type of object, but none of the specific // ones we add in the tests below... setup: function() { - set = SC.Set.create([ + set = SC.Set.create(SC.NativeArray.apply([ SC.Object.create({ dummy: YES }), { isHash: YES }, "Not the String", - 16, true, false, 0]) ; + 16, true, false, 0])) ; }, teardown: function() { @@ -292,11 +292,11 @@ module("SC.Set.pop + SC.Set.copy", { // generate a set with every type of object, but none of the specific // ones we add in the tests below... setup: function() { - set = SC.Set.create([ + set = SC.Set.create(SC.NativeArray.apply([ SC.Object.create({ dummy: YES }), { isHash: YES }, "Not the String", - 16, false]) ; + 16, false])) ; }, teardown: function() { @@ -312,10 +312,10 @@ test("the pop() should remove an arbitrary object from the set", function() { }); test("should pop false and 0", function(){ - set = SC.Set.create([false]); + set = SC.Set.create(SC.NativeArray.apply([false])); ok(set.pop() === false, "should pop false"); - set = SC.Set.create([0]); + set = SC.Set.create(SC.NativeArray.apply([0])); ok(set.pop() === 0, "should pop 0"); });
true
Other
emberjs
ember.js
1fa9fa630fc31a7310fd838c2ee51ac940464a9d.json
Fix EXTEND_PROTOTYPES for sproutcore-runtime
packages/sproutcore-runtime/tests/mixins/array_test.js
@@ -520,7 +520,7 @@ test('modifying the array should also indicate the isDone prop itself has change testBoth("should be clear caches for computed properties that have dependent keys on arrays that are changed after object initialization", function(get, set) { var obj = SC.Object.create({ init: function() { - set(this, 'resources', SC.MutableArray.apply([])); + set(this, 'resources', SC.NativeArray.apply([])); }, common: SC.computed(function() { @@ -541,7 +541,7 @@ testBoth("observers that contain @each in the path should fire only once the fir var obj = SC.Object.create({ init: function() { // Observer fires once when resources changes - set(this, 'resources', SC.MutableArray.apply([])); + set(this, 'resources', SC.NativeArray.apply([])); }, commonDidChange: function() {
true
Other
emberjs
ember.js
1fa9fa630fc31a7310fd838c2ee51ac940464a9d.json
Fix EXTEND_PROTOTYPES for sproutcore-runtime
packages/sproutcore-runtime/tests/mixins/mutable_array_test.js
@@ -15,7 +15,7 @@ var TestMutableArray = SC.Object.extend(SC.MutableArray, { _content: null, init: function(ary) { - this._content = ary || []; + this._content = SC.NativeArray.apply(ary || []); }, replace: function(idx, amt, objects) {
true
Other
emberjs
ember.js
1fa9fa630fc31a7310fd838c2ee51ac940464a9d.json
Fix EXTEND_PROTOTYPES for sproutcore-runtime
packages/sproutcore-runtime/tests/suites/array/indexOf.js
@@ -17,7 +17,7 @@ suite.test("should return index of object", function() { idx; for(idx=0;idx<len;idx++) { - equals(obj.indexOf(expected[idx]), idx, 'obj.indexOf(%@) should match idx'.fmt(expected[idx])); + equals(obj.indexOf(expected[idx]), idx, SC.String.fmt('obj.indexOf(%@) should match idx', expected[idx])); } });
true
Other
emberjs
ember.js
1fa9fa630fc31a7310fd838c2ee51ac940464a9d.json
Fix EXTEND_PROTOTYPES for sproutcore-runtime
packages/sproutcore-runtime/tests/suites/array/objectAt.js
@@ -17,7 +17,7 @@ suite.test("should return object at specified index", function() { idx; for(idx=0;idx<len;idx++) { - equals(obj.objectAt(idx), expected[idx], 'obj.objectAt(%@) should match'.fmt(idx)); + equals(obj.objectAt(idx), expected[idx], SC.String.fmt('obj.objectAt(%@) should match', idx)); } });
true
Other
emberjs
ember.js
1fa9fa630fc31a7310fd838c2ee51ac940464a9d.json
Fix EXTEND_PROTOTYPES for sproutcore-runtime
packages/sproutcore-runtime/tests/system/array_proxy/suite_test.js
@@ -10,7 +10,7 @@ SC.MutableArrayTests.extend({ newObject: function(ary) { var ret = ary ? ary.slice() : this.newFixture(3); - return new SC.ArrayProxy(ret); + return new SC.ArrayProxy(SC.NativeArray.apply(ret)); }, mutate: function(obj) {
true
Other
emberjs
ember.js
1fa9fa630fc31a7310fd838c2ee51ac940464a9d.json
Fix EXTEND_PROTOTYPES for sproutcore-runtime
packages/sproutcore-runtime/tests/system/native_array/copyable_suite_test.js
@@ -11,7 +11,7 @@ SC.CopyableTests.extend({ name: 'NativeArray Copyable', newObject: function() { - return [SC.generateGuid()]; + return SC.NativeArray.apply([SC.generateGuid()]); }, isEqual: function(a,b) {
true
Other
emberjs
ember.js
1fa9fa630fc31a7310fd838c2ee51ac940464a9d.json
Fix EXTEND_PROTOTYPES for sproutcore-runtime
packages/sproutcore-runtime/tests/system/native_array/suite_test.js
@@ -9,7 +9,7 @@ SC.MutableArrayTests.extend({ name: 'Native Array', newObject: function(ary) { - return ary ? ary.slice() : this.newFixture(3); + return SC.NativeArray.apply(ary ? ary.slice() : this.newFixture(3)); }, mutate: function(obj) {
true
Other
emberjs
ember.js
2885a044938380e1e0ed78534f76a830297df1e1.json
Fix EXTEND_PROTOTYPES for sproutcore-datetime
packages/sproutcore-datetime/lib/datetime.js
@@ -1013,7 +1013,7 @@ SC.DateTime.reopenClass(SC.Comparable, if ( opts.month === 2 && opts.day > 29 ){ return null; } - if ([4,6,9,11].contains(opts.month) && opts.day > 30) { + if (jQuery.inArray(opts.month, [4,6,9,11]) > -1 && opts.day > 30) { return null; } }
true
Other
emberjs
ember.js
2885a044938380e1e0ed78534f76a830297df1e1.json
Fix EXTEND_PROTOTYPES for sproutcore-datetime
packages/sproutcore-datetime/tests/datetime_test.js
@@ -33,14 +33,14 @@ function timeShouldBeEqualToHash(t, h, message) { return; } - equals(get(t, 'year'), h.year , message.fmt('year')); - equals(get(t, 'month'), h.month, message.fmt('month')); - equals(get(t, 'day'), h.day, message.fmt('day')); - equals(get(t, 'hour'), h.hour, message.fmt('hour')); - equals(get(t, 'minute'), h.minute, message.fmt('minute')); - equals(get(t, 'second'), h.second, message.fmt('second')); - equals(get(t, 'millisecond'), h.millisecond, message.fmt('millisecond')); - equals(get(t, 'timezone'), h.timezone, message.fmt('timezone')); + equals(get(t, 'year'), h.year , SC.String.fmt(message, 'year')); + equals(get(t, 'month'), h.month, SC.String.fmt(message, 'month')); + equals(get(t, 'day'), h.day, SC.String.fmt(message, 'day')); + equals(get(t, 'hour'), h.hour, SC.String.fmt(message, 'hour')); + equals(get(t, 'minute'), h.minute, SC.String.fmt(message, 'minute')); + equals(get(t, 'second'), h.second, SC.String.fmt(message, 'second')); + equals(get(t, 'millisecond'), h.millisecond, SC.String.fmt(message, 'millisecond')); + equals(get(t, 'timezone'), h.timezone, SC.String.fmt(message, 'timezone')); } function formatTimezone(offset) {
true
Other
emberjs
ember.js
d7a0fa8c76e0ef0b84dcfccf0df973f6bbd92092.json
Fix documentation for template helper
packages/sproutcore-handlebars/lib/helpers/template.js
@@ -24,10 +24,10 @@ require('sproutcore-handlebars/ext'); SC.TEMPLATES["my_cool_template"] = SC.Handlebars.compile('<b>{{user}}</b>'); - @name Handlebars.helpers.unbound - @param {String} property - @returns {String} HTML string + @name Handlebars.helpers.template + @param {String} templateName the template to render */ + SC.Handlebars.registerHelper('template', function(name, options) { var template = SC.TEMPLATES[name];
false
Other
emberjs
ember.js
e57f0c04219f86683bbe32a2a1d802caec98809c.json
Allow binding to this
packages/sproutcore-handlebars/lib/helpers/view.js
@@ -62,7 +62,11 @@ SC.Handlebars.ViewHelper = SC.Object.create({ if (PARENT_VIEW_PATH.test(path)) { SC.Logger.warn("As of SproutCore 2.0 beta 3, it is no longer necessary to bind to parentViews. Instead, please provide binding paths relative to the current Handlebars context."); } else { - options[prop] = 'bindingContext.'+path; + if (path === 'this') { + options[prop] = 'bindingContext'; + } else { + options[prop] = 'bindingContext.'+path; + } } } }
true
Other
emberjs
ember.js
e57f0c04219f86683bbe32a2a1d802caec98809c.json
Allow binding to this
packages/sproutcore-handlebars/tests/handlebars_test.js
@@ -1302,6 +1302,28 @@ test("bindings should be relative to the current context", function() { equals($.trim(view.$().text()), "Name: SFMoMA Price: $20", "should print baz twice"); }); +test("bindings can be 'this', in which case they *are* the current context", function() { + view = SC.View.create({ + museumOpen: true, + + museumDetails: SC.Object.create({ + name: "SFMoMA", + price: 20, + museumView: SC.View.extend({ + template: SC.Handlebars.compile('Name: {{museum.name}} Price: ${{museum.price}}') + }), + }), + + + template: SC.Handlebars.compile('{{#if museumOpen}} {{#with museumDetails}}{{view museumView museumBinding="this"}} {{/with}}{{/if}}') + }); + + SC.run(function() { + view.appendTo('#qunit-fixture'); + }); + + equals($.trim(view.$().text()), "Name: SFMoMA Price: $20", "should print baz twice"); +}); // https://github.com/sproutcore/sproutcore20/issues/120
true
Other
emberjs
ember.js
3e525e29c0b1f906186f202fe95a9246401d7de3.json
Add detectInstance to classes
packages/sproutcore-runtime/lib/system/core_object.js
@@ -181,6 +181,10 @@ var ClassMixin = SC.Mixin.create({ obj = obj.superclass; } return false; + }, + + detectInstance: function(obj) { + return this.PrototypeMixin.detect(obj); } });
true
Other
emberjs
ember.js
3e525e29c0b1f906186f202fe95a9246401d7de3.json
Add detectInstance to classes
packages/sproutcore-runtime/tests/legacy_1x/system/object/base_test.js
@@ -145,6 +145,11 @@ test("Checking the detect() function on an object and its subclass", function(){ equals(obj1.detect(obj), NO); }); +test("Checking the detectInstance() function on an object and its subclass", function() { + ok(SC.Object.detectInstance(obj.create())); + ok(obj.detectInstance(obj.create())); +}); + test("subclasses should contain defined subclasses", function() { ok(obj.subclasses.contains(obj1), 'obj.subclasses should contain obj1');
true
Other
emberjs
ember.js
4532f0a3afeab665f244acef9139f99de477b93d.json
Add disabled binding to all controls
packages/sproutcore-handlebars/lib/controls/button.js
@@ -11,9 +11,10 @@ SC.Button = SC.View.extend({ classNameBindings: ['isActive'], tagName: 'button', - attributeBindings: ['type'], + attributeBindings: ['type', 'disabled'], type: 'button', - + disabled: false, + targetObject: function() { var target = get(this, 'target');
true
Other
emberjs
ember.js
4532f0a3afeab665f244acef9139f99de477b93d.json
Add disabled binding to all controls
packages/sproutcore-handlebars/lib/controls/checkbox.js
@@ -17,10 +17,11 @@ var set = SC.set, get = SC.get; SC.Checkbox = SC.View.extend({ title: null, value: false, + disabled: false, classNames: ['sc-checkbox'], - defaultTemplate: SC.Handlebars.compile('<label><input type="checkbox" {{bindAttr checked="value"}}>{{title}}</label>'), + defaultTemplate: SC.Handlebars.compile('<label><input type="checkbox" {{bindAttr checked="value" disabled="disabled"}}>{{title}}</label>'), change: function() { SC.run.once(this, this._updateElementValue);
true
Other
emberjs
ember.js
4532f0a3afeab665f244acef9139f99de477b93d.json
Add disabled binding to all controls
packages/sproutcore-handlebars/lib/controls/text_area.js
@@ -16,8 +16,9 @@ SC.TextArea = SC.View.extend({ tagName: "textarea", value: "", - attributeBindings: ['placeholder'], + attributeBindings: ['placeholder', 'disabled'], placeholder: null, + disabled: false, insertNewline: SC.K, cancel: SC.K,
true
Other
emberjs
ember.js
4532f0a3afeab665f244acef9139f99de477b93d.json
Add disabled binding to all controls
packages/sproutcore-handlebars/lib/controls/text_field.js
@@ -19,10 +19,11 @@ SC.TextField = SC.View.extend( cancel: SC.K, tagName: "input", - attributeBindings: ['type', 'placeholder', 'value'], + attributeBindings: ['type', 'placeholder', 'value', 'disabled'], type: "text", value: "", placeholder: null, + disabled: false, focusOut: function(event) { this._elementValueDidChange();
true
Other
emberjs
ember.js
4532f0a3afeab665f244acef9139f99de477b93d.json
Add disabled binding to all controls
packages/sproutcore-handlebars/lib/views/metamorph_view.js
@@ -31,6 +31,7 @@ SC.Metamorph = SC.Mixin.create({ domManagerClass: SC.Object.extend({ remove: function(view) { var morph = getPath(this, 'view.morph'); + if (morph.isRemoved()) { return; } getPath(this, 'view.morph').remove(); },
true
Other
emberjs
ember.js
4532f0a3afeab665f244acef9139f99de477b93d.json
Add disabled binding to all controls
packages/sproutcore-handlebars/tests/controls/button_test.js
@@ -24,6 +24,30 @@ function synthesizeEvent(type, view) { view.$().trigger(type); } +function append() { + SC.run(function() { + button.appendTo('#qunit-fixture'); + }); +} + +test("should become disabled if the disabled attribute is true", function() { + button.set('disabled', true); + append(); + + ok(button.$().is(":disabled")); +}); + +test("should become disabled if the disabled attribute is true", function() { + append(); + ok(button.$().is(":not(:disabled)")); + + SC.run(function() { button.set('disabled', true); }); + ok(button.$().is(":disabled")); + + SC.run(function() { button.set('disabled', false); }); + ok(button.$().is(":not(:disabled)")); +}); + test("should trigger an action when clicked", function() { var wasClicked = false;
true
Other
emberjs
ember.js
4532f0a3afeab665f244acef9139f99de477b93d.json
Add disabled binding to all controls
packages/sproutcore-handlebars/tests/controls/checkbox_test.js
@@ -22,6 +22,34 @@ function setAndFlush(view, key, value) { }); } +function append() { + SC.run(function() { + checkboxView.appendTo('#qunit-fixture'); + }); +} + +test("should become disabled if the disabled attribute is true", function() { + checkboxView = SC.Checkbox.create({}); + + checkboxView.set('disabled', true); + append(); + + ok(checkboxView.$("input").is(":disabled")); +}); + +test("should become disabled if the disabled attribute is true", function() { + checkboxView = SC.Checkbox.create({}); + + append(); + ok(checkboxView.$("input").is(":not(:disabled)")); + + SC.run(function() { checkboxView.set('disabled', true); }); + ok(checkboxView.$("input").is(":disabled")); + + SC.run(function() { checkboxView.set('disabled', false); }); + ok(checkboxView.$("input").is(":not(:disabled)")); +}); + test("value property mirrors input value", function() { checkboxView = SC.Checkbox.create({}); SC.run(function() { checkboxView.append(); });
true
Other
emberjs
ember.js
4532f0a3afeab665f244acef9139f99de477b93d.json
Add disabled binding to all controls
packages/sproutcore-handlebars/tests/controls/text_area_test.js
@@ -23,6 +23,30 @@ module("SC.TextArea", { } }); +function append() { + SC.run(function() { + textArea.appendTo('#qunit-fixture'); + }); +} + +test("should become disabled if the disabled attribute is true", function() { + textArea.set('disabled', true); + append(); + + ok(textArea.$().is(":disabled")); +}); + +test("should become disabled if the disabled attribute is true", function() { + append(); + ok(textArea.$().is(":not(:disabled)")); + + SC.run(function() { textArea.set('disabled', true); }); + ok(textArea.$().is(":disabled")); + + SC.run(function() { textArea.set('disabled', false); }); + ok(textArea.$().is(":not(:disabled)")); +}); + test("input value is updated when setting value property of view", function() { SC.run(function() { set(textArea, 'value', 'foo');
true
Other
emberjs
ember.js
4532f0a3afeab665f244acef9139f99de477b93d.json
Add disabled binding to all controls
packages/sproutcore-handlebars/tests/controls/text_field_test.js
@@ -23,6 +23,30 @@ module("SC.TextField", { } }); +function append() { + SC.run(function() { + textField.appendTo('#qunit-fixture'); + }); +} + +test("should become disabled if the disabled attribute is true", function() { + textField.set('disabled', true); + append(); + + ok(textField.$().is(":disabled")); +}); + +test("should become disabled if the disabled attribute is true", function() { + append(); + ok(textField.$().is(":not(:disabled)")); + + SC.run(function() { textField.set('disabled', true); }); + ok(textField.$().is(":disabled")); + + SC.run(function() { textField.set('disabled', false); }); + ok(textField.$().is(":not(:disabled)")); +}); + test("input value is updated when setting value property of view", function() { SC.run(function() { set(textField, 'value', 'foo');
true
Other
emberjs
ember.js
e27f9fe458ad798bacd545c10ba3b53104b5bc9c.json
Use arguments rather than an array of keys
packages/sproutcore-runtime/lib/mixins/observable.js
@@ -67,17 +67,17 @@ SC.Observable = SC.Mixin.create(/** @scope SC.Observable.prototype */ { /** To get multiple properties at once, call getProperties - with an Array: + with a list of strings: - record.getProperties(['firstName', 'lastName', 'zipCode']); + record.getProperties('firstName', 'lastName', 'zipCode'); - @param {Array} array of keys to get + @param {String...} list of keys to get @returns {Hash} */ - getProperties: function(keyNames) { + getProperties: function() { var ret = {}; - for(var i = 0; i < keyNames.length; i++) { - ret[keyNames[i]] = get(this, keyNames[i]); + for(var i = 0; i < arguments.length; i++) { + ret[arguments[i]] = get(this, arguments[i]); } return ret; },
true
Other
emberjs
ember.js
e27f9fe458ad798bacd545c10ba3b53104b5bc9c.json
Use arguments rather than an array of keys
packages/sproutcore-runtime/tests/mixins/observable_test.js
@@ -10,10 +10,10 @@ test('should be able to use getProperties to get a POJO of provided keys', funct var obj = SC.Object.create({ firstName: "Steve", lastName: "Jobs", - zipCode: 94301 + companyName: "Apple, Inc." }); - var pojo = obj.getProperties("firstName lastName".w()); + var pojo = obj.getProperties("firstName", "lastName"); equals("Steve", pojo.firstName); equals("Jobs", pojo.lastName); }); \ No newline at end of file
true
Other
emberjs
ember.js
770452df78031bd6a42f28879259bec160abe523.json
Allow use of {{this}} inside {{#each}}
packages/sproutcore-handlebars/lib/helpers/binding.js
@@ -47,8 +47,12 @@ var get = SC.get, getPath = SC.getPath, set = SC.set, fmt = SC.String.fmt; }); // Observes the given property on the context and - // tells the SC._BindableSpan to re-render. - SC.addObserver(ctx, property, observer); + // tells the SC._BindableSpan 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 (property !== '') { + SC.addObserver(ctx, property, observer); + } } else { // The object is not observable, so just render it out and // be done with it.
true
Other
emberjs
ember.js
770452df78031bd6a42f28879259bec160abe523.json
Allow use of {{this}} inside {{#each}}
packages/sproutcore-handlebars/lib/views/bindable_span.js
@@ -109,7 +109,16 @@ SC._BindableSpanView = SC.View.extend(SC.Metamorph, var inverseTemplate = get(this, 'inverseTemplate'), displayTemplate = get(this, 'displayTemplate'); - var result = getPath(context, property); + var result; + + + // Use the current context as the result if no + // property is provided. + if (property === '') { + result = context; + } else { + result = getPath(context, property); + } // First, test the conditional to see if we should // render the template or not.
true
Other
emberjs
ember.js
770452df78031bd6a42f28879259bec160abe523.json
Allow use of {{this}} inside {{#each}}
packages/sproutcore-handlebars/tests/each_test.js
@@ -41,5 +41,16 @@ test("it updates the view if an item is added", function() { people.pushObject({ name: "Tom Dale" }); }); - assertHTML(view, "Steve HoltAnnabelleTom Dale") + assertHTML(view, "Steve HoltAnnabelleTom Dale"); +}); + +test("it allows you to access the current context using {{this}}", function() { + view = SC.View.create({ + template: templateFor("{{#each people}}{{this}}{{/each}}"), + people: ['Black Francis', 'Joey Santiago', 'Kim Deal', 'David Lovering'] + }); + + append(view); + + assertHTML(view, "Black FrancisJoey SantiagoKim DealDavid Lovering"); });
true
Other
emberjs
ember.js
68e5dadca88bb0b4cf9bcdd00d3ac970ea28be39.json
Add getProperties method to SC.Observable
packages/sproutcore-runtime/lib/mixins/observable.js
@@ -64,6 +64,23 @@ SC.Observable = SC.Mixin.create(/** @scope SC.Observable.prototype */ { get: function(keyName) { return get(this, keyName); }, + + /** + To get multiple properties at once, call getProperties + with an Array: + + record.getProperties(['firstName', 'lastName', 'zipCode']); + + @param {Array} array of keys to get + @returns {Hash} + */ + getProperties: function(keyNames) { + var ret = {}; + for(var i = 0; i < keyNames.length; i++) { + ret[keyNames[i]] = get(this, keyNames[i]); + } + return ret; + }, /** Sets the key equal to value.
true
Other
emberjs
ember.js
68e5dadca88bb0b4cf9bcdd00d3ac970ea28be39.json
Add getProperties method to SC.Observable
packages/sproutcore-runtime/tests/mixins/observable_test.js
@@ -0,0 +1,19 @@ +// ========================================================================== +// Project: SproutCore Runtime +// Copyright: ©2011 Strobe Inc. and contributors. +// License: Licensed under MIT license (see license.js) +// ========================================================================== + +module('mixins/observable'); + +test('should be able to use getProperties to get a POJO of provided keys', function() { + var obj = SC.Object.create({ + firstName: "Steve", + lastName: "Jobs", + zipCode: 94301 + }); + + var pojo = obj.getProperties("firstName lastName".w()); + equals("Steve", pojo.firstName); + equals("Jobs", pojo.lastName); +}); \ No newline at end of file
true
Other
emberjs
ember.js
d191f7bf142c54d29ab25e3389f0f0e8a964efcf.json
Fix binding tests to not use SC.Object
packages/sproutcore-metal/tests/binding/and_test.js
@@ -8,11 +8,11 @@ var MyApp, set = SC.set, get = SC.get; module('binding/and', { setup: function() { - MyApp = SC.Object.create({ + MyApp = { foo: false, - bar: false, - bazBinding: SC.Binding.and('foo', 'bar') - }); + bar: false + }; + SC.Binding.and("foo", "bar").to("baz").connect(MyApp) }, teardown: function() {
true
Other
emberjs
ember.js
d191f7bf142c54d29ab25e3389f0f0e8a964efcf.json
Fix binding tests to not use SC.Object
packages/sproutcore-metal/tests/binding/bool_not_test.js
@@ -15,10 +15,10 @@ function testBool(val, expected) { module('system/binding/bool', { setup: function() { - MyApp = SC.Object.create({ - foo: SC.Object.create({ value: 'FOO' }), - bar: SC.Object.create({ value: 'BAR' }) - }); + MyApp = { + foo: { value: 'FOO' }, + bar: { value: 'BAR' } + }; SC.bind(MyApp, 'bar.value', 'foo.value').bool(); }, @@ -44,10 +44,10 @@ testBool('', false); module('system/binding/not', { setup: function() { - MyApp = SC.Object.create({ - foo: SC.Object.create({ value: 'FOO' }), - bar: SC.Object.create({ value: 'BAR' }) - }); + MyApp = { + foo: { value: 'FOO' }, + bar: { value: 'BAR' } + }; SC.bind(MyApp, 'bar.value', 'foo.value').not(); },
true
Other
emberjs
ember.js
d191f7bf142c54d29ab25e3389f0f0e8a964efcf.json
Fix binding tests to not use SC.Object
packages/sproutcore-metal/tests/binding/connect_test.js
@@ -36,7 +36,7 @@ function performTest(binding, a, b, get, set, skipFirst) { } testBoth('Connecting a binding between two properties', function(get, set) { - var a = SC.Object.create({ foo: 'FOO', bar: 'BAR' }); + var a = { foo: 'FOO', bar: 'BAR' }; // a.bar -> a.foo var binding = new SC.Binding('foo', 'bar'); @@ -45,8 +45,8 @@ testBoth('Connecting a binding between two properties', function(get, set) { }); testBoth('Connecting a binding between two objects', function(get, set) { - var b = SC.Object.create({ bar: 'BAR' }); - var a = SC.Object.create({ foo: 'FOO', b: b }); + var b = { bar: 'BAR' }; + var a = { foo: 'FOO', b: b }; // b.bar -> a.foo var binding = new SC.Binding('foo', 'b.bar'); @@ -55,10 +55,10 @@ testBoth('Connecting a binding between two objects', function(get, set) { }); testBoth('Connecting a binding to path', function(get, set) { - var a = SC.Object.create({ foo: 'FOO' }); - GlobalB = SC.Object.create({ - b: SC.Object.create({ bar: 'BAR' }) - }) ; + var a = { foo: 'FOO' }; + GlobalB = { + b: { bar: 'BAR' } + }; var b = get(GlobalB, 'b'); @@ -68,16 +68,16 @@ testBoth('Connecting a binding to path', function(get, set) { performTest(binding, a, b, get, set); // make sure modifications update - b = SC.Object.create({ bar: 'BIFF' }); + b = { bar: 'BIFF' }; set(GlobalB, 'b', b); SC.run.sync(); equals(get(a, 'foo'), 'BIFF', 'a should have changed'); }); testBoth('Calling connect more than once', function(get, set) { - var b = SC.Object.create({ bar: 'BAR' }); - var a = SC.Object.create({ foo: 'FOO', b: b }); + var b = { bar: 'BAR' }; + var a = { foo: 'FOO', b: b }; // b.bar -> a.foo var binding = new SC.Binding('foo', 'b.bar'); @@ -107,13 +107,12 @@ testBoth('Bindings should be inherited', function(get, set) { test('inherited bindings should sync on create', function() { - var A = SC.Object.extend({ - fooBinding: 'bar.baz' - }); + var A = function() { + SC.bind(this, 'foo', 'bar.baz'); + }; - var a = A.create({ - bar: SC.Object.create({ baz: 'BAZ' }) - }); + var a = new A(); + SC.set(a, 'bar', { baz: 'BAZ' }); SC.run.sync(); equals(SC.get(a, 'foo'), 'BAZ', 'should have synced binding on new obj');
true
Other
emberjs
ember.js
d191f7bf142c54d29ab25e3389f0f0e8a964efcf.json
Fix binding tests to not use SC.Object
packages/sproutcore-metal/tests/binding/multiple_test.js
@@ -7,10 +7,10 @@ module('system/binding/multiple', { setup: function() { - MyApp = SC.Object.create({ - foo: SC.Object.create({ value: 'FOO' }), - bar: SC.Object.create({ value: 'BAR' }) - }); + MyApp = { + foo: { value: 'FOO' }, + bar: { value: 'BAR' } + }; }, teardown: function() {
true
Other
emberjs
ember.js
d191f7bf142c54d29ab25e3389f0f0e8a964efcf.json
Fix binding tests to not use SC.Object
packages/sproutcore-metal/tests/binding/notEmpty_test.js
@@ -7,10 +7,10 @@ module('system/binding/notEmpty', { setup: function() { - MyApp = SC.Object.create({ - foo: SC.Object.create({ value: 'FOO' }), - bar: SC.Object.create({ value: 'BAR' }) - }); + MyApp = { + foo: { value: 'FOO' }, + bar: { value: 'BAR' } + }; }, teardown: function() {
true
Other
emberjs
ember.js
d191f7bf142c54d29ab25e3389f0f0e8a964efcf.json
Fix binding tests to not use SC.Object
packages/sproutcore-metal/tests/binding/notNull_test.js
@@ -7,10 +7,10 @@ module('system/binding/notNull', { setup: function() { - MyApp = SC.Object.create({ - foo: SC.Object.create({ value: 'FOO' }), - bar: SC.Object.create({ value: 'BAR' }) - }); + MyApp = { + foo: { value: 'FOO' }, + bar: { value: 'BAR' } + }; }, teardown: function() {
true
Other
emberjs
ember.js
d191f7bf142c54d29ab25e3389f0f0e8a964efcf.json
Fix binding tests to not use SC.Object
packages/sproutcore-metal/tests/binding/oneWay_test.js
@@ -7,9 +7,9 @@ module('system/mixin/binding/oneWay_test', { setup: function() { - MyApp = SC.Object.create({ - foo: SC.Object.create({ value: 'FOO' }), - bar: SC.Object.create({ value: 'BAR' }) + MyApp = { + foo: { value: 'FOO' }, + bar: { value: 'BAR' } }); },
true
Other
emberjs
ember.js
d191f7bf142c54d29ab25e3389f0f0e8a964efcf.json
Fix binding tests to not use SC.Object
packages/sproutcore-metal/tests/binding/single_test.js
@@ -7,10 +7,10 @@ module('system/binding/single', { setup: function() { - MyApp = SC.Object.create({ - foo: SC.Object.create({ value: 'FOO' }), - bar: SC.Object.create({ value: 'BAR' }) - }); + MyApp = { + foo: { value: 'FOO' }, + bar: { value: 'BAR' } + }; }, teardown: function() {
true
Other
emberjs
ember.js
13260bf514863b5453ee5bd5073c1dabd16d94c9.json
Improve mixin function, remove object require.
packages/sproutcore-runtime/lib/system/binding.js
@@ -5,7 +5,6 @@ // ========================================================================== /*globals sc_assert */ -require('sproutcore-runtime/system/object'); require('sproutcore-runtime/system/run_loop'); // .......................................................... @@ -692,15 +691,15 @@ Binding.prototype = { }; -function mixinClassMethods(obj, classMethods) { - for (var key in classMethods) { - if (typeof classMethods[key] === 'function') { - obj[key] = classMethods[key]; +function mixinProperties(to, from) { + for (var key in from) { + if (from.hasOwnProperty(key)) { + to[key] = from[key]; } } }; -mixinClassMethods(Binding, { +mixinProperties(Binding, { /** @see SC.Binding.prototype.from
false
Other
emberjs
ember.js
94d0bb71aa1fa8bc82a902aa608ea4b29d043aac.json
Fix comment typo in SC.inspect
packages/sproutcore-runtime/lib/core.js
@@ -292,7 +292,7 @@ SC.copy = function(obj, deep) { Convenience method to inspect an object. This method will attempt to convert the object into a useful string description. - @param {Object} obj The object you want to inspec. + @param {Object} obj The object you want to inspect. @returns {String} A description of the object */ SC.inspect = function(obj) {
false
Other
emberjs
ember.js
817a8c840c83aa90aa084dbab1182bd7e712bb83.json
Add helper for exception-safe beginPropertyChanges I found myself using this pattern enough that I think it belongs in the library. This is a safer way to use beginPropertyChanges. It's analogous to using the block form of Ruby's "open", or using Python's "with" statement.
packages/sproutcore-metal/lib/observer.js
@@ -84,6 +84,15 @@ SC.endPropertyChanges = function() { if (suspended<=0) flushObserverQueue(); }; +SC.batchPropertyChanges = function(cb){ + SC.beginPropertyChanges(); + try { + cb() + } finally { + SC.endPropertyChanges(); + } +} + function changeEvent(keyName) { return keyName+AFTER_OBSERVERS; }
true
Other
emberjs
ember.js
817a8c840c83aa90aa084dbab1182bd7e712bb83.json
Add helper for exception-safe beginPropertyChanges I found myself using this pattern enough that I think it belongs in the library. This is a safer way to use beginPropertyChanges. It's analogous to using the block form of Ruby's "open", or using Python's "with" statement.
packages/sproutcore-metal/tests/observer_test.js
@@ -74,6 +74,35 @@ testBoth('suspending property changes will defer', function(get,set) { equals(fooCount, 1, 'foo should have fired once'); }); +testBoth('suspending property changes safely despite exceptions', function(get,set) { + var obj = { foo: 'foo' }; + var fooCount = 0; + var exc = new Error("Something unexpected happened!"); + + expect(2); + SC.addObserver(obj, 'foo' ,function() { fooCount++; }); + + try { + SC.batchPropertyChanges(function(){ + set(obj, 'foo', 'BIFF'); + set(obj, 'foo', 'BAZ'); + throw exc; + }); + } catch(err) { + if (err != exc) + throw err; + } + + equals(fooCount, 1, 'foo should have fired once'); + + SC.batchPropertyChanges(function(){ + set(obj, 'foo', 'BIFF2'); + set(obj, 'foo', 'BAZ2'); + }); + + equals(fooCount, 2, 'foo should have fired again once'); +}); + testBoth('suspending property changes will not defer before observers', function(get,set) { var obj = { foo: 'foo' }; var fooCount = 0;
true
Other
emberjs
ember.js
aba456d48fb58d1ece980a542abb5e38476930ac.json
remove debugging cruft
packages/sproutcore-touch/tests/gesture_recognizers/pan_test.js
@@ -135,9 +135,7 @@ test("If the touches move, the translation should reflect the change", function( }] }; - window.foo=true; view.$().trigger(touchEvent); - window.foo=false; equals(get(get(get(view, 'eventManager'), 'gestures')[0], 'state'),SC.Gesture.BEGAN, "gesture should be BEGAN");
false
Other
emberjs
ember.js
ce52f618113242a8464e38eac94c984ddac1c72c.json
Extract SC.TouchList into its own file
packages/sproutcore-touch/lib/system/gesture.js
@@ -12,77 +12,6 @@ var set = SC.set; var sigFigs = 100; -SC.TouchList = SC.Object.extend({ - touches: null, - - timestamp: null, - - init: function() { - this._super(); - - set(this, 'touches', []); - }, - - addTouch: function(touch) { - var touches = get(this, 'touches'); - touches.push(touch); - this.notifyPropertyChange('touches'); - }, - - updateTouch: function(touch) { - var touches = get(this, 'touches'); - - for (var i=0, l=touches.length; i<l; i++) { - var _t = touches[i]; - - if (_t.identifier === touch.identifier) { - touches[i] = touch; - this.notifyPropertyChange('touches'); - break; - } - } - }, - - removeTouch: function(touch) { - var touches = get(this, 'touches'); - - for (var i=0, l=touches.length; i<l; i++) { - var _t = touches[i]; - - if (_t.identifier === touch.identifier) { - touches.splice(i,1); - this.notifyPropertyChange('touches'); - break; - } - } - }, - - removeAllTouches: function() { - set(this, 'touches', []); - }, - - touchWithId: function(id) { - var ret = null, - touches = get(this, 'touches'); - - for (var i=0, l=touches.length; i<l; i++) { - var _t = touches[i]; - - if (_t.identifier === id) { - ret = _t; - break; - } - } - - return ret; - }, - - length: function() { - var touches = get(this, 'touches'); - return touches.length; - }.property('touches').cacheable() -}); - /** @class
true
Other
emberjs
ember.js
ce52f618113242a8464e38eac94c984ddac1c72c.json
Extract SC.TouchList into its own file
packages/sproutcore-touch/lib/system/touch_list.js
@@ -0,0 +1,86 @@ +// ========================================================================== +// Project: SproutCore Touch +// Copyright: ©2011 Strobe Inc. and contributors. +// License: Licensed under MIT license (see license.js) +// ========================================================================== + +var get = SC.get; +var set = SC.set; + +/** + @class + @private + + Used to manage and maintain a list of active touches related to a gesture + recognizer. +*/ +SC.TouchList = SC.Object.extend({ + touches: null, + + timestamp: null, + + init: function() { + this._super(); + + set(this, 'touches', []); + }, + + addTouch: function(touch) { + var touches = get(this, 'touches'); + touches.push(touch); + this.notifyPropertyChange('touches'); + }, + + updateTouch: function(touch) { + var touches = get(this, 'touches'); + + for (var i=0, l=touches.length; i<l; i++) { + var _t = touches[i]; + + if (_t.identifier === touch.identifier) { + touches[i] = touch; + this.notifyPropertyChange('touches'); + break; + } + } + }, + + removeTouch: function(touch) { + var touches = get(this, 'touches'); + + for (var i=0, l=touches.length; i<l; i++) { + var _t = touches[i]; + + if (_t.identifier === touch.identifier) { + touches.splice(i,1); + this.notifyPropertyChange('touches'); + break; + } + } + }, + + removeAllTouches: function() { + set(this, 'touches', []); + }, + + touchWithId: function(id) { + var ret = null, + touches = get(this, 'touches'); + + for (var i=0, l=touches.length; i<l; i++) { + var _t = touches[i]; + + if (_t.identifier === id) { + ret = _t; + break; + } + } + + return ret; + }, + + length: function() { + var touches = get(this, 'touches'); + return touches.length; + }.property('touches').cacheable() +});
true
Other
emberjs
ember.js
b03a2da383f375ee6766df46900dd440a83165ce.json
Fix typo in enumerable docs
packages/sproutcore-runtime/lib/mixins/enumerable.js
@@ -91,7 +91,7 @@ SC.Enumerable = SC.Mixin.create( /** @lends SC.Enumerable */ { to nextObject for the current iteration. This is a useful way to manage iteration if you are tracing a linked list, for example. - Finally the context paramter will always contain a hash you can use as + Finally the context parameter will always contain a hash you can use as a "scratchpad" to maintain any other state you need in order to iterate properly. The context object is reused and is not reset between iterations so make sure you setup the context with a fresh state whenever
false
Other
emberjs
ember.js
20b6082b02a16dc6bc720bfebb6a404743435667.json
Fix math bug in pinch
packages/sproutcore-touch/lib/gesture_recognizers/pinch.js
@@ -118,7 +118,7 @@ SC.PinchGestureRecognizer = SC.Gesture.extend({ var distanceDifference = (currentDistanceBetweenTouches - this._previousDistance); set(this, 'velocity', distanceDifference / timeDifference); - set(this, 'scale', distanceDifference / this._previousDistance); + set(this, 'scale', currentDistanceBetweenTouches / this._previousDistance); this._previousTimestamp = get(this.touches,'timestamp'); this._previousDistance = currentDistanceBetweenTouches;
false
Other
emberjs
ember.js
a1131aa5fe698167043240e40893f71d7bb2ceaf.json
Fix bugs with pan since changing API for cssHooks
packages/sproutcore-touch/lib/gesture_recognizers/pan.js
@@ -87,11 +87,11 @@ SC.PanGestureRecognizer = SC.Gesture.extend({ }, shouldBegin: function() { - var previous = this._previousLocation; - var current = this.centerPointForTouches(get(this.touches,'touches')); + var previousLocation = this._previousLocation; + var currentLocation = this.centerPointForTouches(get(this.touches,'touches')); - var x = this._previousLocation.x; - var y = this._previousLocation.y; + var x = previousLocation.x; + var y = previousLocation.y; var x0 = currentLocation.x; var y0 = currentLocation.y; @@ -100,16 +100,16 @@ SC.PanGestureRecognizer = SC.Gesture.extend({ }, didChange: function() { - var previous = this._previousLocation; - var current = this.centerPointForTouches(get(this.touches,'touches')); - var translation = {x:current.x,y:current.y}; + var previousLocation = this._previousLocation; + var currentLocation = this.centerPointForTouches(get(this.touches,'touches')); + var translation = {x:currentLocation.x, y:currentLocation.y}; - translation.x = current.x - previous.x; - translation.y = current.y - previous.y; + translation.x = currentLocation.x - previousLocation.x; + translation.y = currentLocation.y - previousLocation.y; this._previousTranslation = get(this, 'translation'); set(this, 'translation', translation); - this._previousLocation = current; + this._previousLocation = currentLocation; }, eventWasRejected: function() {
false
Other
emberjs
ember.js
5b89dfdb7db918e839c61e2f99c77a76c63dd3e5.json
Fix package.jsons for subprojects
packages/handlebars/package.json
@@ -4,7 +4,7 @@ "description": "A semantic templating language for JavaScript", "homepage": "http://www.handlebarsjs.com", "author": "Yehuda Katz", - "version": "1.0.0.beta.2", + "version": "1.0.0.beta.3", "directories": { "lib": "lib"
true
Other
emberjs
ember.js
5b89dfdb7db918e839c61e2f99c77a76c63dd3e5.json
Fix package.jsons for subprojects
packages/sproutcore-handlebars-format/package.json
@@ -1,8 +1,9 @@ { "name": "sproutcore-handlebars-format", - "version": "2.0.beta.3", + "version": "1.0.1", "description": "Adds format support for handlebars templates", "homepage": "http://www.sproutcore.com", + "author": "Charles Jolley", "bpm:build": { "bpm_libs.js": {
true
Other
emberjs
ember.js
5b89dfdb7db918e839c61e2f99c77a76c63dd3e5.json
Fix package.jsons for subprojects
packages/sproutcore-handlebars/package.json
@@ -7,11 +7,10 @@ "version": "2.0.beta.3", "dependencies": { "spade": "~> 1.0.0", - "handlebars": "~> 1.0.0.beta.2", + "handlebars": "~> 1.0.0.beta.3", "sproutcore-views": "2.0.beta.3", - "sproutcore-runtime": "2.0.beta.3", - "sproutcore-handlebars-format": "~> 2.0.beta.3" - }, + "sproutcore-handlebars-format": "~> 2.0.beta.3" + } "directories": { "lib": "lib"
true
Other
emberjs
ember.js
5b89dfdb7db918e839c61e2f99c77a76c63dd3e5.json
Fix package.jsons for subprojects
packages/sproutcore/package.json
@@ -11,7 +11,7 @@ "sproutcore-runtime": "2.0.beta.3", "sproutcore-views": "2.0.beta.3", "sproutcore-handlebars": "2.0.beta.3", - "sproutcore-handlebars-format": "2.0.beta.3" + "sproutcore-handlebars-format": "~> 1.0.0" }, "directories": { @@ -31,5 +31,4 @@ "main": "sproutcore-handlebars-format/format" } } - }
true
Other
emberjs
ember.js
525345a968eb2e523e192c7f74c5e8117bbe2f08.json
Fix broken package dependencies. Fixed #126
packages/sproutcore-handlebars/package.json
@@ -10,7 +10,7 @@ "handlebars": "~> 1.0.0.beta.2", "sproutcore-views": "2.0.beta.3", "sproutcore-runtime": "2.0.beta.3", - "sproutcore-handlebars-format": "~> 1.0.0" + "sproutcore-handlebars-format": "~> 2.0.beta.3" }, "directories": {
true
Other
emberjs
ember.js
525345a968eb2e523e192c7f74c5e8117bbe2f08.json
Fix broken package dependencies. Fixed #126
packages/sproutcore-touch/package.json
@@ -13,7 +13,7 @@ "dependencies": { "spade" : "~> 1.0", "jquery" : "~> 1.6", - "sproutcore-views" : "2.0.beta.2" + "sproutcore-views" : "2.0.beta.3" }, "dependencies:development": {
true
Other
emberjs
ember.js
525345a968eb2e523e192c7f74c5e8117bbe2f08.json
Fix broken package dependencies. Fixed #126
packages/sproutcore/package.json
@@ -8,10 +8,10 @@ "dependencies": { "spade": "~> 1.0.0", - "sproutcore-runtime": "2.0.beta.3" - "sproutcore-views": "2.0.beta.3" - "sproutcore-handlebars": "2.0.beta.3" - "sproutcore-handlebars-format": "~> 1.0.0" + "sproutcore-runtime": "2.0.beta.3", + "sproutcore-views": "2.0.beta.3", + "sproutcore-handlebars": "2.0.beta.3", + "sproutcore-handlebars-format": "2.0.beta.3" }, "directories": {
true
Other
emberjs
ember.js
cdace7e3957374f2dcb02e89eebf05dacfa1b66a.json
Remove references to spaderun from readme
README.md
@@ -119,7 +119,4 @@ example, to run all of the unit tests together: # Adding New Packages -Be sure you include the new package as a dependency in the global `package.json` and run `spaderun update`. - -Note that unless you are adding new __tests__ or adding a new package you should not need to run `spaderun update`. - +Be sure you include the new package as a dependency in the global `package.json`.
false
Other
emberjs
ember.js
87aac6902b8113179ffb2e731850d2706370baba.json
Add support for two-way binding transforms
packages/sproutcore-runtime/lib/system/binding.js
@@ -8,8 +8,6 @@ require('sproutcore-runtime/system/object'); require('sproutcore-runtime/system/run_loop'); - - // .......................................................... // CONSTANTS // @@ -125,7 +123,10 @@ function getTransformedValue(binding, val, obj, dir) { len = transforms ? transforms.length : 0, idx; - for(idx=0;idx<len;idx++) { val = transforms[idx][dir].call(this, val, obj); } + for(idx=0;idx<len;idx++) { + var transform = transforms[idx][dir]; + if (transform) { val = transform.call(this, val, obj); } + } return val; } @@ -139,6 +140,11 @@ function getTransformedFromValue(obj, binding) { return getTransformedValue(binding, fromValue, obj, 'to'); } +function getTransformedToValue(obj, binding) { + var toValue = getPath(obj, binding._to); + return getTransformedValue(binding, toValue, obj, 'from'); +} + var AND_OPERATION = function(obj, left, right) { return getPath(obj, left) && getPath(obj, right); }; @@ -402,7 +408,9 @@ var Binding = SC.Object.extend({ @returns {SC.Binding} this */ transform: function(transform) { - sc_assert("Binding transforms must be a hash with a `to` and optional `from` property", transform && transform.to); + if ('function' === typeof transform) { + transform = { to: transform }; + } if (!this._transforms) this._transforms = []; this._transforms.push(transform); @@ -654,7 +662,7 @@ var Binding = SC.Object.extend({ // apply any operations to the object, then apply transforms var fromValue = getTransformedFromValue(obj, this); - var toValue = getPath(obj, toPath); + var toValue = getTransformedToValue(obj, this); if (toValue === fromValue) { return; }
true
Other
emberjs
ember.js
87aac6902b8113179ffb2e731850d2706370baba.json
Add support for two-way binding transforms
packages/sproutcore-runtime/tests/system/binding/transform_test.js
@@ -5,7 +5,7 @@ // ========================================================================== /*globals MyApp */ -var foo, bar; +var foo, bar, binding, set = SC.set, get = SC.get, setPath = SC.setPath; var CountObject = SC.Object.extend({ value: null, @@ -34,20 +34,21 @@ module('system/mixin/binding/transform_test', { }, teardown: function() { + binding.disconnect(MyApp); MyApp = null; } }); test('returns this', function() { - var binding = new SC.Binding('foo.value', 'bar.value'); + binding = new SC.Binding('foo.value', 'bar.value'); var ret = binding.transform({ from: function() {}, to: function() {} }); equals(ret, binding); }); test('transform function should be invoked on fwd change', function() { - var binding = SC.bind(MyApp, 'foo.value', 'bar.value'); + binding = SC.bind(MyApp, 'foo.value', 'bar.value'); binding.transform({ to: function(value) { return 'TRANSFORMED'; }}); SC.run.sync(); @@ -56,10 +57,33 @@ test('transform function should be invoked on fwd change', function() { equals(SC.getPath('MyApp.bar.value'), 'BAR', 'should stay original'); }); +test('two-way transforms work', function() { + SC.run(function() { + binding = SC.bind(MyApp, 'foo.value', 'bar.value'); + binding.transform({ + to: function(string) { + return parseInt(string) || null; + }, + from: function(integer) { + return String(integer); + } + }); + }); + + SC.run(function() { + setPath(MyApp, 'bar.value', "1"); + }); + + equals(SC.getPath('MyApp.foo.value'), 1, "sets the value to a number"); + + setPath(MyApp, 'foo.value', 1); + equals(SC.getPath('MyApp.bar.value'), "1", "sets the value to a string"); +}); + test('transform function should NOT be invoked on fwd change', function() { var count = 0; - var binding = SC.bind(MyApp, 'foo.value', 'bar.value'); + binding = SC.bind(MyApp, 'foo.value', 'bar.value'); var lastSeenValue; binding.transform({ to: function(value) { @@ -86,7 +110,7 @@ test('transform function should NOT be invoked on fwd change', function() { }); test('transforms should chain', function() { - var binding = SC.bind(MyApp, 'foo.value', 'bar.value'); + binding = SC.bind(MyApp, 'foo.value', 'bar.value'); binding.transform({ to: function(value) { return value+' T1'; } }); @@ -101,7 +125,7 @@ test('transforms should chain', function() { }); test('resetTransforms() should clear', function() { - var binding = SC.bind(MyApp, 'foo.value', 'bar.value'); + binding = SC.bind(MyApp, 'foo.value', 'bar.value'); binding.transform({ to: function(value) { return value+' T1'; } });
true
Other
emberjs
ember.js
0ffa758cd39fbc11c38fe00011457c218feb39f3.json
Remove debugger statement from unit test
packages/sproutcore-handlebars/tests/handlebars_test.js
@@ -1204,10 +1204,8 @@ test("should not enter an infinite loop when binding an attribute in Handlebars" classNames: ['app-link'], tagName: 'a', attributeBindings: ['href'], - // href: '#none', - href: function(key, value) { - debugger; - }.property(), + href: '#none', + click: function() { return false; }
false
Other
emberjs
ember.js
bc03cd87d3ed927468702b6bf3fe130a06c317eb.json
Add unit test for GH Issue #120
packages/sproutcore-handlebars/tests/handlebars_test.js
@@ -1193,3 +1193,38 @@ test("bindings should be relative to the current context", function() { equals($.trim(view.$().text()), "Name: SFMoMA Price: $20", "should print baz twice"); }); + + +// https://github.com/sproutcore/sproutcore20/issues/120 + +test("should not enter an infinite loop when binding an attribute in Handlebars", function() { + App = SC.Application.create(); + App.test = SC.Object.create({ href: 'test' }); + App.Link = SC.View.extend({ + classNames: ['app-link'], + tagName: 'a', + attributeBindings: ['href'], + // href: '#none', + href: function(key, value) { + debugger; + }.property(), + click: function() { + return false; + } + }); + + var parentView = SC.View.create({ + template: SC.Handlebars.compile('{{#view App.Link hrefBinding="App.test.href"}} Test {{/view}}') + }); + + + SC.run(function() { + parentView.appendTo('#qunit-fixture'); + // App.Link.create().appendTo('#qunit-fixture'); + }); + // equals(view.$().attr('href'), 'test'); + + parentView.destroy(); + + App = undefined; +});
true
Other
emberjs
ember.js
bc03cd87d3ed927468702b6bf3fe130a06c317eb.json
Add unit test for GH Issue #120
packages/sproutcore-views/tests/views/view/attribute_bindings_test.js
@@ -78,10 +78,9 @@ test("should allow attributes to be set in the inBuffer state", function() { parentView.append(); }); - window.billy = true; equals(parentView.get('childViews')[0].$().attr('foo'), 'baz'); - window.billy = false; parentView.destroy(); }); +
true
Other
emberjs
ember.js
df1726a0295ce33d1cd1d5540f7f4ebdfd47b07f.json
Add some better errors for set
packages/sproutcore-metal/lib/accessors.js
@@ -55,19 +55,21 @@ if (!USE_ACCESSORS) { var o_get = get, o_set = set; get = function(obj, keyName) { - if (keyName === undefined && 'string' === typeof obj) { keyName = obj; obj = SC; } + sc_assert("You need to provide an object and key to `get`.", obj && keyName); + if (!obj) return undefined; var desc = meta(obj, false).descs[keyName]; if (desc) return desc.get(obj, keyName); else return o_get(obj, keyName); }; set = function(obj, keyName, value) { + sc_assert("You need to provide an object, key and value to `set`.", obj && keyName && value !== undefined); var desc = meta(obj, false).descs[keyName]; if (desc) desc.set(obj, keyName, value); else o_set(obj, keyName, value);
true
Other
emberjs
ember.js
df1726a0295ce33d1cd1d5540f7f4ebdfd47b07f.json
Add some better errors for set
packages/sproutcore-metal/lib/utils.js
@@ -172,6 +172,8 @@ if (Object.freeze) Object.freeze(EMPTY_META); @returns {Hash} */ SC.meta = function meta(obj, writable) { + sc_assert("You must pass an object to SC.meta. This was probably called from SproutCore internals, so you probably called a SproutCore method with undefined that was expecting an object", obj); + var ret = obj[META_KEY]; if (writable===false) return ret || EMPTY_META;
true
Other
emberjs
ember.js
8282f906e183143095f6fcbf2aa991089dd4b216.json
Add ability to unregister gestures from the system
packages/sproutcore-touch/lib/system/gestures.js
@@ -45,6 +45,14 @@ SC.Gestures = SC.Object.create( registeredGestures[name] = recognizer; }, + unregister: function(name) { + var registeredGestures = this._registeredGestures; + + if (registeredGestures[name] !== undefined) { + registeredGestures[name] = undefined; + } + }, + /** Registers a gesture recognizer to the system. The gesture recognizer is identified by the name parameter, which must be unique across the system.
true
Other
emberjs
ember.js
8282f906e183143095f6fcbf2aa991089dd4b216.json
Add ability to unregister gestures from the system
packages/sproutcore-touch/tests/system/gestures_test.js
@@ -40,3 +40,20 @@ test("register new gestures", function() { ok(caught); }); +test("unregister a gesture", function() { + var myGesture = SC.Gesture.create({ + isMyGesture: true + }); + + SC.Gestures.register('myGesture2',myGesture); + + var newGestures = SC.Gestures.knownGestures(); + + equals(newGestures['myGesture2'],myGesture, "registered gesture is added"); + + SC.Gestures.unregister('myGesture2'); + + newGestures = SC.Gestures.knownGestures(); + equals(newGestures['myGesture2'],undefined, "registered gesture is unregistered"); +}); +
true
Other
emberjs
ember.js
274a545562554f631eb85a99874a26f433d97f3a.json
Fix failing unit tests in tap gesture recognizer
packages/sproutcore-touch/lib/gesture_recognizers/tap.js
@@ -47,13 +47,21 @@ SC.TapGestureRecognizer = SC.Gesture.extend({ didBegin: function() { this._initialLocation = this.centerPointForTouches(this._touches); - this._waitingForMoreTouches = true; - this._waitingInterval = window.setInterval(this._intervalFired,this.MULTITAP_DELAY); + if (this._numActiveTouches < get(this, 'numberOfTaps')) { + this._waitingForMoreTouches = true; + this._waitingInterval = window.setInterval(this._intervalFired,this.MULTITAP_DELAY); + } }, shouldEnd: function() { var currentLocation = this.centerPointForTouches(this._touches); - var distance = this.distance([this._initialLocation,currentLocation]); + + var x = this._initialLocation.x; + var y = this._initialLocation.y; + var x0 = currentLocation.x; + var y0 = currentLocation.y; + + var distance = Math.sqrt((x -= x0) * x + (y -= y0) * y); return (distance <= this._moveThreshold) && !this._waitingForMoreTouches; },
true
Other
emberjs
ember.js
274a545562554f631eb85a99874a26f433d97f3a.json
Fix failing unit tests in tap gesture recognizer
packages/sproutcore-touch/lib/system/gesture.js
@@ -129,6 +129,7 @@ SC.Gesture = SC.Object.extend( if (get(this, 'gestureIsDiscrete') && this.shouldBegin()) { set(this, 'state', SC.Gesture.BEGAN); this.didBegin(); + this.attemptGestureEventDelivery(evt, view, get(this, 'name')+'Start'); } else { set(this, 'state', SC.Gesture.POSSIBLE); this.didBecomePossible();
true
Other
emberjs
ember.js
274a545562554f631eb85a99874a26f433d97f3a.json
Fix failing unit tests in tap gesture recognizer
packages/sproutcore-touch/tests/gesture_recognizers/tap_test.js
@@ -53,7 +53,7 @@ module("Tap Test",{ } }); -test("one start event should put it in possible state", function() { +test("one start event should put it in began state", function() { var numStart = 0; var touchEvent = jQuery.Event('touchstart'); touchEvent['originalEvent'] = { @@ -69,7 +69,7 @@ test("one start event should put it in possible state", function() { ok(gestures); equals(gestures.length,1); - equals(get(gestures[0], 'state'),SC.Gesture.POSSIBLE, "gesture should be possible"); + equals(get(gestures[0], 'state'),SC.Gesture.BEGAN, "gesture should be began"); }); test("when touch ends, tap should fire", function() { @@ -83,22 +83,28 @@ test("when touch ends, tap should fire", function() { pageY: 10 }] }; + view.$().trigger(touchEvent); + var gestures = get(get(view, 'eventManager'), 'gestures'); + ok(startCalled, 'tapStart should be called on the view'); + ok(gestures, "gestures should exist"); + equals(gestures.length,1); + equals(get(gestures[0], 'state'),SC.Gesture.BEGAN, "gesture should be began"); touchEvent = new jQuery.Event(); touchEvent.type='touchend'; touchEvent['originalEvent'] = { changedTouches: [{ - pageX: 20, + pageX: 5, pageY: 10 }] }; view.$().trigger(touchEvent); - var gestures = get(get(view, 'eventManager'), 'gestures'); + gestures = get(get(view, 'eventManager'), 'gestures'); ok(endCalled,'tap should be ended'); ok(gestures, "gestures should exist");
true
Other
emberjs
ember.js
4487868a59e62df945b98ab90280888b3534b480.json
Fix required file in ArrayController.
packages/sproutcore-runtime/lib/controllers/array_controller.js
@@ -4,6 +4,8 @@ // License: Licensed under MIT license (see license.js) // ========================================================================== +require('sproutcore-runtime/system/array_proxy'); + /** @class
false
Other
emberjs
ember.js
69d1e7f5aab8afecd10500c158a9f954cb5e8065.json
Add stubs for methods that may not be implemented
packages/sproutcore-touch/lib/system/gesture.js
@@ -175,14 +175,17 @@ SC.Gesture = SC.Object.extend( touchEnd: function(evt, view, manager) { if (get(this, 'gestureIsDiscrete')) { + if (this.state === SC.Gesture.BEGAN && this.gestureShouldEnd()) { set(this, 'state', SC.Gesture.ENDED); this.attemptGestureEventDelivery(evt, view, get(this, 'name')+'End'); + } else { set(this, 'state', SC.Gesture.CANCELLED); this.attemptGestureEventDelivery(evt, view, get(this, 'name')+'Cancel'); } } else { + if (this.state !== SC.Gesture.ENDED) { this._resetState(); set(this, 'state', SC.Gesture.ENDED); @@ -203,13 +206,19 @@ SC.Gesture = SC.Object.extend( } }, - gestureBecamePossible: function() {}, - gestureChanged: function() {}, - gestureShouldBegin: function() { return true; }, + gestureBecamePossible: function() { + + }, + + gestureChanged: function() { + + }, + + gestureShouldEnd: function() { return true; },
false
Other
emberjs
ember.js
f5dd39206f9727952b7a583ac60ba7630c2305b1.json
Preserve old behavior for special '@each' keys. While it would be better to rewrite EachProxy, that would be a much bigger change.
packages/sproutcore-metal/lib/watching.js
@@ -136,6 +136,11 @@ var ChainNode = function(parent, key, value, separator) { this._object = parent.value(); if (this._object) addChainWatcher(this._object, this._key, this); } + + // Special-case: the EachProxy relies on immediate evaluation to + // establish its observers. + if (this._parent && this._parent._key === '@each') + this.value(); }; @@ -305,6 +310,11 @@ Wp.didChange = function() { addChainWatcher(obj, this._key, this); } this._value = undefined; + + // Special-case: the EachProxy relies on immediate evaluation to + // establish its observers. + if (this._parent && this._parent._key === '@each') + this.value(); } // then notify chains...
false
Other
emberjs
ember.js
576b3b3a5cdeb70bb1796b252c9b421827c17e09.json
remove magictouch require
packages/sproutcore-touch/lib/system.js
@@ -1,5 +1,4 @@ require('sproutcore-touch/system/gesture'); require('sproutcore-touch/system/view'); -require('sproutcore-touch/system/magictouch'); require('sproutcore-touch/system/gesture_manager'); require('sproutcore-touch/system/gestures');
false
Other
emberjs
ember.js
0b3739b559f206de25befdbbabf212ac8843a240.json
Fix bugs in pinch behavior
packages/sproutcore-touch/lib/gesture_recognizers/pinch.js
@@ -100,14 +100,18 @@ SC.PinchGestureRecognizer = SC.Gesture.extend({ }, touchMove: function(evt, view, manager) { + if (this.state === SC.Gesture.ENDED || this.state === SC.Gesture.CANCELLED) { + manager.redispatchEventToView(view,'touchmove', evt); + return; + } var changedTouches = evt.originalEvent.changedTouches; var _touches = this._touches; for (var i=0, l=changedTouches.length; i<l; i++) { var touch = changedTouches[i]; - if (_touches[touch.identifier] === undefined) { - throw new SC.Error('touchMove somehow got a changedTouch that was not being tracked'); - } + //if (_touches[touch.identifier] === undefined) { + //throw new SC.Error('touchMove somehow got a changedTouch that was not being tracked'); + //} _touches[touch.identifier] = touch; } @@ -122,7 +126,6 @@ SC.PinchGestureRecognizer = SC.Gesture.extend({ } var currentDistanceBetweenTouches = this.distance(touches); - console.log(currentDistanceBetweenTouches); var nominator = currentDistanceBetweenTouches; var denominator = this._startingDistanceBetweenTouches; @@ -152,7 +155,7 @@ SC.PinchGestureRecognizer = SC.Gesture.extend({ this.notifyViewOfGestureEvent(view,'pinchEnd'); } - manager.redispatchEventToView(view,'touchmove', evt); + manager.redispatchEventToView(view,'touchend', evt); }, touchCancel: function(evt, view, manager) {
false
Other
emberjs
ember.js
0bb1a5a1ab73c89faee1ae27be978399ad18a534.json
Add statechart building to Rakefile
Rakefile
@@ -53,7 +53,7 @@ end # Create sproutcore:package tasks for each of the SproutCore packages namespace :sproutcore do - %w(metal indexset runtime handlebars views datastore).each do |package| + %w(metal indexset runtime handlebars views datastore statechart).each do |package| task package => compile_package_task("sproutcore-#{package}") end end @@ -62,7 +62,7 @@ end task :handlebars => compile_package_task("handlebars") # Create a build task that depends on all of the package dependencies -task :build => ["sproutcore:metal", "sproutcore:indexset", "sproutcore:runtime", "sproutcore:handlebars", "sproutcore:views", "sproutcore:datastore", :handlebars] +task :build => ["sproutcore:metal", "sproutcore:indexset", "sproutcore:runtime", "sproutcore:handlebars", "sproutcore:views", "sproutcore:datastore", "sproutcore:statechart", :handlebars] # Strip out require lines from sproutcore.js. For the interim, requires are # precomputed by the compiler so they are no longer necessary at runtime. @@ -93,6 +93,18 @@ file "dist/sproutcore-datastore.js" => [:build] do end end +# Strip out require lines from sproutcore-statechart.js. For the interim, requires are +# precomputed by the compiler so they are no longer necessary at runtime. +file "dist/sproutcore-statechart.js" => [:build] do + puts "Generating sproutcore-statechart.js" + + mkdir_p "dist" + + File.open("dist/sproutcore-statechart.js", "w") do |file| + file.puts strip_require("tmp/static/sproutcore-statechart.js") + end +end + # Minify dist/sproutcore.js to dist/sproutcore.min.js file "dist/sproutcore.min.js" => "dist/sproutcore.js" do puts "Generating sproutcore.min.js" @@ -117,6 +129,15 @@ file "dist/sproutcore-datastore.min.js" => "dist/sproutcore-datastore.js" do end end +# Minify dist/sproutcore-statechart.js to dist/sproutcore-statechart.min.js +file "dist/sproutcore-statechart.min.js" => "dist/sproutcore-statechart.js" do + puts "Generating sproutcore-statechart.min.js" + + File.open("dist/sproutcore-statechart.min.js", "w") do |file| + file.puts uglify("dist/sproutcore-statechart.js") + end +end + SC_VERSION = File.read("VERSION") desc "bump the version to the specified version" @@ -191,7 +212,7 @@ namespace :starter_kit do end desc "Build SproutCore and SproutCore Datastore" -task :dist => ["dist/sproutcore.min.js", "dist/sproutcore-datastore.min.js"] +task :dist => ["dist/sproutcore.min.js", "dist/sproutcore-datastore.min.js", "dist/sproutcore-statechart.min.js"] desc "Clean build artifacts from previous builds" task :clean do
false
Other
emberjs
ember.js
c013c8899bceb52a500431cbd28272716d45a98a.json
Remove unneeded variables.
packages/sproutcore-handlebars/lib/helpers/debug.js
@@ -7,7 +7,7 @@ require('sproutcore-handlebars/ext'); -var get = SC.get, getPath = SC.getPath; +var getPath = SC.getPath; /** `log` allows you to output the value of a value in the current rendering
true
Other
emberjs
ember.js
c013c8899bceb52a500431cbd28272716d45a98a.json
Remove unneeded variables.
packages/sproutcore-handlebars/lib/helpers/unbound.js
@@ -7,7 +7,7 @@ require('sproutcore-handlebars/ext'); -var get = SC.get, getPath = SC.getPath; +var getPath = SC.getPath; /** `unbound` allows you to output a property without binding. *Important:* The
true
Other
emberjs
ember.js
7e85b964408e75678fd74d447007a1bdb9d50ed0.json
Add a couple of debugging Handlebars extensions
packages/sproutcore-handlebars/lib/helpers.js
@@ -8,3 +8,4 @@ require("sproutcore-handlebars/helpers/binding"); require("sproutcore-handlebars/helpers/collection"); require("sproutcore-handlebars/helpers/view"); require("sproutcore-handlebars/helpers/unbound"); +require("sproutcore-handlebars/helpers/debug");
true
Other
emberjs
ember.js
7e85b964408e75678fd74d447007a1bdb9d50ed0.json
Add a couple of debugging Handlebars extensions
packages/sproutcore-handlebars/lib/helpers/debug.js
@@ -0,0 +1,36 @@ +// ========================================================================== +// Project: SproutCore Handlebar Views +// Copyright: ©2011 Strobe Inc. and contributors. +// License: Licensed under MIT license (see license.js) +// ========================================================================== +/*globals Handlebars */ + +require('sproutcore-handlebars/ext'); + +var get = SC.get, getPath = SC.getPath; + +/** + `log` allows you to output the value of a value in the current rendering + context. + + {{log myVariable}} + + @name Handlebars.helpers.log + @param {String} property +*/ +Handlebars.registerHelper('log', function(property) { + console.log(getPath(this, property)); +}); + +/** + The `debugger` helper executes the `debugger` statement in the current + context. + + {{log myVariable}} + + @name Handlebars.helpers.log + @param {String} property +*/ +Handlebars.registerHelper('debugger', function() { + debugger; +});
true
Other
emberjs
ember.js
4d492e426b3c92b432babedb770d8b74aef6317d.json
add KEY_EVENTS support to TextArea
packages/sproutcore-handlebars/lib/controls/text_area.js
@@ -18,6 +18,9 @@ SC.TextArea = SC.View.extend({ value: "", attributeBindings: ['placeholder'], placeholder: null, + + insertNewline: SC.K, + cancel: SC.K, focusOut: function(event) { this._elementValueDidChange(); @@ -30,7 +33,7 @@ SC.TextArea = SC.View.extend({ }, keyUp: function(event) { - this._elementValueDidChange(); + this.interpretKeyEvents(event); return false; }, @@ -41,11 +44,24 @@ SC.TextArea = SC.View.extend({ this._updateElementValue(); }, + interpretKeyEvents: function(event) { + var map = SC.TextArea.KEY_EVENTS; + var method = map[event.keyCode]; + + if (method) { return this[method](event); } + else { this._elementValueDidChange(); } + }, + _elementValueDidChange: function() { set(this, 'value', this.$().val()); }, _updateElementValue: function() { this.$().val(get(this, 'value')); }.observes('value') -}); \ No newline at end of file +}); + +SC.TextArea.KEY_EVENTS = { + 13: 'insertNewline', + 27: 'cancel' +};
true
Other
emberjs
ember.js
4d492e426b3c92b432babedb770d8b74aef6317d.json
add KEY_EVENTS support to TextArea
packages/sproutcore-handlebars/tests/controls/text_area_test.js
@@ -72,6 +72,34 @@ test("value binding works properly for inputs that haven't been created", functi equals(textArea.$().val(), 'ohai', "value is reflected in the input element once it is created"); }); +test("should call the insertNewline method when return key is pressed", function() { + var wasCalled; + var event = SC.Object.create({ + keyCode: 13 + }); + + textArea.insertNewline = function() { + wasCalled = true; + }; + + textArea.keyUp(event); + ok(wasCalled, "invokes insertNewline method"); +}); + +test("should call the cancel method when escape key is pressed", function() { + var wasCalled; + var event = SC.Object.create({ + keyCode: 27 + }); + + textArea.cancel = function() { + wasCalled = true; + }; + + textArea.keyUp(event); + ok(wasCalled, "invokes cancel method"); +}); + // test("listens for focus and blur events", function() { // var focusCalled = 0; // var blurCalled = 0;
true
Other
emberjs
ember.js
c2e621384c1b72ee4dc22b8f09c4ab2bcf2e222b.json
Destroy App created in handlebars test
packages/sproutcore-handlebars/tests/views/collection_view_test.js
@@ -84,7 +84,7 @@ test("empty views should be removed when content is added to the collection (reg equals(view.$('tr').length, 1, 'has one row'); - window.App = undefined; + window.App.destroy(); }); test("if no content is passed, and no 'else' is specified, nothing is rendered", function() {
false
Other
emberjs
ember.js
17a06e487e23cacc890b9c9a8177f97e4fb9acf5.json
Add unit test for nested event managers
packages/sproutcore-touch/tests/system/nested_event_managers.js
@@ -0,0 +1,80 @@ +// ========================================================================== +// Project: SproutCore Runtime +// Copyright: ©2011 Strobe Inc. and contributors. +// License: Licensed under MIT license (see license.js) +// ========================================================================== + +var set = SC.set; +var get = SC.get; +var application; + +module("Nested event managers", { + setup: function() { + application = SC.Application.create(); + }, + + teardown: function() { + application.destroy(); + } +}); + +test("Nested event managers should get called appropriately", function() { + + SC.Gestures.register('nestedEventManagerTestGesture',SC.Gesture.extend({ + touchStart: function(evt, view, manager) { + this.notifyViewOfGestureEvent(view, 'nestedEventManagerTestGestureStart'); + manager.redispatchEventToView(view,'touchstart'); + } + })); + + SC.Gestures.register('nestedViewTestGesture',SC.Gesture.extend({ + touchStart: function(evt, view, manager) { + this.notifyViewOfGestureEvent(view, 'nestedViewTestGestureStart'); + manager.redispatchEventToView(view,'touchstart'); + } + })); + + var callNumber = 0; + + var view = SC.ContainerView.create({ + + childViews: ['nestedView'], + + nestedView: SC.View.extend({ + elementId: 'nestedTestView', + + nestedViewTestGestureStart: function() { + equals(callNumber,0,'nested manager called first'); + callNumber++; + }, + + touchStart: function() { + equals(callNumber,1,'nested view called second'); + callNumber++; + } + }), + + nestedEventManagerTestGestureStart: function() { + equals(callNumber,2,'parent manager called third'); + callNumber++; + }, + + touchStart: function() { + equals(callNumber,3,'parent view called fourth'); + callNumber++; + } + }); + + SC.run(function(){ + view.append(); + }); + + var gestures = get(get(view, 'eventManager'), 'gestures'); + + ok(gestures); + equals(gestures.length,1); + + $('#nestedTestView').trigger('touchstart'); + +}); +
false
Other
emberjs
ember.js
98fe46e280893efc9a5dfd6b6c9815fc007a4fe7.json
Move object destruction to the end of the run loop.
packages/sproutcore-runtime/lib/system/core_object.js
@@ -75,12 +75,34 @@ CoreObject.PrototypeMixin = SC.Mixin.create({ isDestroyed: false, + /** + Destroys an object by setting the isDestroyed flag and removing its + metadata, which effectively destroys observers and bindings. + + If you try to set a property on a destroyed object, an exception will be + raised. + + Note that destruction is scheduled for the end of the run loop and does not + happen immediately. + + @returns {SC.Object} receiver + */ destroy: function() { set(this, 'isDestroyed', true); - this[SC.META_KEY] = null; + SC.run.schedule('destroy', this, this._scheduledDestroy); return this; }, + /** + Invoked by the run loop to actually destroy the object. This is + scheduled for execution by the `destroy` method. + + @private + */ + _scheduledDestroy: function() { + this[SC.META_KEY] = null; + }, + bind: function(to, from) { if (!(from instanceof SC.Binding)) { from = SC.Binding.from(from); } from.to(to).connect(this);
true
Other
emberjs
ember.js
98fe46e280893efc9a5dfd6b6c9815fc007a4fe7.json
Move object destruction to the end of the run loop.
packages/sproutcore-runtime/lib/system/run_loop.js
@@ -206,7 +206,7 @@ SC.run.end = function() { @property {String} */ -SC.run.queues = ['sync', 'actions', 'timers']; +SC.run.queues = ['sync', 'actions', 'destroy', 'timers']; /** Adds the passed target/method and any optional arguments to the named
true
Other
emberjs
ember.js
98fe46e280893efc9a5dfd6b6c9815fc007a4fe7.json
Move object destruction to the end of the run loop.
packages/sproutcore-runtime/tests/system/object/destroy_test.js
@@ -0,0 +1,36 @@ +// ========================================================================== +// Project: SproutCore Runtime +// Copyright: ©2011 Strobe Inc. and contributors. +// License: Licensed under MIT license (see license.js) +// ========================================================================== +/*globals raises TestObject */ + +module('sproutcore-runtime/system/object/destroy_test'); + +test("should schedule objects to be destroyed at the end of the run loop", function() { + var obj = SC.Object.create(); + + SC.run(function() { + var meta; + obj.destroy(); + meta = SC.meta(obj); + ok(meta, "object is not destroyed immediately"); + }); + + ok(obj.get('isDestroyed'), "object is destroyed after run loop finishes"); +}); + +test("should raise an exception when modifying watched properties on a destroyed object", function() { + var obj = SC.Object.create({ + foo: "bar", + fooDidChange: SC.observer(function() { }, 'foo') + }); + + SC.run(function() { + obj.destroy(); + }); + + raises(function() { + SC.set(obj, 'foo', 'baz'); + }, Error, "raises an exception"); +});
true
Other
emberjs
ember.js
98fe46e280893efc9a5dfd6b6c9815fc007a4fe7.json
Move object destruction to the end of the run loop.
packages/sproutcore-runtime/tests/system/object/observer_test.js
@@ -116,7 +116,7 @@ testBoth('observer should not fire after being destroyed', function(get, set) { equals(get(obj, 'count'), 0, 'precond - should not invoke observer immediately'); - obj.destroy(); + SC.run(function() { obj.destroy(); }); raises(function() { set(obj, 'bar', "BAZ");
true
Other
emberjs
ember.js
98fe46e280893efc9a5dfd6b6c9815fc007a4fe7.json
Move object destruction to the end of the run loop.
packages/sproutcore-views/lib/system/event_dispatcher.js
@@ -105,14 +105,15 @@ SC.EventDispatcher = SC.Object.extend( result = true, manager = null; if (!handled) { - manager = self._findNearestEventManager(view,eventName); + manager = self._findNearestEventManager(view, eventName); } if (manager) { result = self._dispatchEvent(manager, evt, eventName, view); - } - else { - result = self._bubbleEvent(view,evt,eventName); + } else if (view) { + result = self._bubbleEvent(view, evt, eventName); + } else { + evt.stopPropagation(); } return result;
true
Other
emberjs
ember.js
98fe46e280893efc9a5dfd6b6c9815fc007a4fe7.json
Move object destruction to the end of the run loop.
packages/sproutcore-views/lib/views/view.js
@@ -395,7 +395,7 @@ SC.View = SC.Object.extend( $: function(sel) { var elem = get(this, 'element'); - if (!elem) { + if (!elem && !get(this, 'isDestroyed')) { // if we don't have an element yet, someone calling this.$() is // trying to update an element that isn't in the DOM. Instead, // rerender the view to allow the render method to reflect the
true
Other
emberjs
ember.js
98fe46e280893efc9a5dfd6b6c9815fc007a4fe7.json
Move object destruction to the end of the run loop.
packages/sproutcore-views/tests/system/event_dispatcher_test.js
@@ -79,7 +79,6 @@ test("should dispatch events to views", function() { equals(parentKeyDownCalled, 0, "does not call keyDown on parent if child handles event"); }); - test("should send change events up view hierarchy if view contains form elements", function() { var receivedEvent; view = SC.View.create({ @@ -101,6 +100,39 @@ test("should send change events up view hierarchy if view contains form elements equals(receivedEvent.target, SC.$('#is-done')[0], "target property is the element that was clicked"); }); +test("events should stop propagating if the view is destroyed", function() { + var parentViewReceived, receivedEvent; + + var parentView = SC.ContainerView.create({ + change: function(evt) { + parentViewReceived = true; + } + }); + + view = parentView.createChildView(SC.View, { + render: function(buffer) { + buffer.push('<input id="is-done" type="checkbox">'); + }, + + change: function(evt) { + receivedEvent = true; + get(this, 'parentView').destroy(); + } + }); + + SC.get(parentView, 'childViews').pushObject(view); + + SC.run(function() { + parentView.append(); + }); + + ok(SC.$('#is-done').length, "precond - view is in the DOM"); + SC.$('#is-done').trigger('change'); + ok(!SC.$('#is-done').length, "precond - view is not in the DOM"); + ok(receivedEvent, "calls change method when a child element is changed"); + ok(!parentViewReceived, "parent view does not receive the event"); +}); + test("should not interfere with event propagation", function() { var receivedEvent; view = SC.View.create({
true
Other
emberjs
ember.js
f2e0cdcaefd1eed03474de518e414e9a2fb413b3.json
Remove sproutcore-touch from default dependencies
packages/sproutcore-touch/package.json
@@ -4,7 +4,7 @@ "description": "The SproutCore touch system", "homepage": "http://sproutcore.com", "author": "Majd Taby", - "version": "2.0.beta.2.pre", + "version": "2.0.beta.2.1.pre", "dependencies": { "spade" : "~> 1.0", "jquery" : "~> 1.6",
true
Other
emberjs
ember.js
f2e0cdcaefd1eed03474de518e414e9a2fb413b3.json
Remove sproutcore-touch from default dependencies
packages/sproutcore/package.json
@@ -4,15 +4,14 @@ "summary": "SproutCore - JavaScript Application Framework", "homepage": "http://github.com/sproutcore/sproutcore20", "author": "Charles Jolley", - "version": "2.0.beta.2.pre", + "version": "2.0.beta.2.1.pre", "dependencies": { "spade": "~> 1.0.0", "sproutcore-runtime": "2.0.beta.2.pre", "sproutcore-views": "2.0.beta.2.pre", "sproutcore-datastore": "2.0.beta.2.pre", - "sproutcore-handlebars": "2.0.beta.2.pre", - "sproutcore-touch": "2.0.beta.2.pre" + "sproutcore-handlebars": "2.0.beta.2.pre" }, "directories": {
true
Other
emberjs
ember.js
bf04b895f6ea812a6c2748266d9691cb9b9164c2.json
Add spade dependency to sproutcore-touch
packages/sproutcore-touch/package.json
@@ -6,8 +6,9 @@ "author": "Majd Taby", "version": "2.0.beta.2.pre", "dependencies": { - "jquery": "~> 1.6", - "sproutcore-views": "2.0.beta.2.pre" + "spade" : "~> 1.0", + "jquery" : "~> 1.6", + "sproutcore-views" : "2.0.beta.2.pre" }, "directories": { "lib" : "./lib",
true
Other
emberjs
ember.js
bf04b895f6ea812a6c2748266d9691cb9b9164c2.json
Add spade dependency to sproutcore-touch
packages/sproutcore/package.json
@@ -12,7 +12,7 @@ "sproutcore-views": "2.0.beta.2.pre", "sproutcore-datastore": "2.0.beta.2.pre", "sproutcore-handlebars": "2.0.beta.2.pre", - "sproutcore-touch": "2.0.beta.2.pre" + "sproutcore-touch": "2.0.beta.2.pre" }, "bpm:build": {
true
Other
emberjs
ember.js
e5b8957890820f2bac7b8cb551d6cd90207cd278.json
Resolve merge conflict in Handlebars unit tests
packages/sproutcore-handlebars/lib/helpers/binding.js
@@ -32,7 +32,8 @@ var get = SC.get, getPath = SC.getPath, fmt = SC.String.fmt; inverseTemplate: inverse, property: property, previousContext: ctx, - isEscaped: options.hash.escaped + isEscaped: options.hash.escaped, + tagName: options.hash.tagName || 'span' }); var observer, invoker;
true
Other
emberjs
ember.js
e5b8957890820f2bac7b8cb551d6cd90207cd278.json
Resolve merge conflict in Handlebars unit tests
packages/sproutcore-handlebars/tests/handlebars_test.js
@@ -1092,14 +1092,47 @@ test("should be able to output a property without binding", function(){ equals(view.$('div').html(), "No spans here, son."); }); +test("should be able to choose a tagName other than span", function(){ + var template = SC.Handlebars.compile('{{#if content.underwater tagName="abbr"}}Hold your breath.{{/if}}'); + var content = SC.Object.create({ + underwater: true + }); + + var view = SC.View.create({ + template: template, + content: content + }); + + view.createElement(); + + equals(view.$('abbr').length, 1); +}); + +test("should still get a span by default if tagName isn't specified", function(){ + var template = SC.Handlebars.compile('{{#if content.underwater}}Hold your breath.{{/if}}'); + var content = SC.Object.create({ + underwater: true + }); + + var view = SC.View.create({ + template: template, + content: content + }); + + view.createElement(); + + equals(view.$('span').length, 1); +}); + module("Templates redrawing and bindings", { setup: function(){ MyApp = SC.Object.create({}); }, teardown: function(){ window.MyApp = null; } -}) +}); + test("should be able to update when bound property updates", function(){ MyApp.set('controller', SC.Object.create({name: 'first'})) @@ -1126,5 +1159,5 @@ test("should be able to update when bound property updates", function(){ equals(view.get('computed'), "second - computed", "view computed properties correctly update"); equals(view.$('i').text(), 'second, second - computed', "view rerenders when bound properties change"); -}) +});
true
Other
emberjs
ember.js
8a9c1a68188af818a3874a7ecba7a7683c5d0389.json
Add note about SproutCore Guides to the README.
README.md
@@ -83,6 +83,8 @@ For new users, we recommend downloading the [SproutCore Starter Kit](https://git We also recommend that you check out the [annotated Todos example](http://annotated-todos.strobeapp.com/), which shows you the best practices for architecting an MVC-based web application. +The [SproutCore Guides are available](http://guides.sproutcore20.com/) for SproutCore 2.0. If you find an error, please [fork the guides on GitHub](https://github.com/sproutcore/sproutguides/tree/v2.0) and submit a pull request. (Note that 2.0 guides are on the `v2.0` branch.) + To learn more about what we're up to, follow [@sproutcore on Twitter](http://twitter.com/sproutcore), [subscribe to the blog](http://blog.sproutcore.com), or [read the original SproutCore 2.0 announcement](http://blog.sproutcore.com/announcing-sproutcore-2-0/). # Building SproutCore 2.0
false