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
e46e056f1d5ed3136efbdf2136febebacd0461c6.json
use peekMeta + deleteMeta is isolate the code-base.
packages/ember-metal/lib/property_get.js
@@ -11,6 +11,9 @@ import { isPath, hasThis as pathHasThis } from 'ember-metal/path_cache'; +import { + peekMeta +} from 'ember-metal/meta'; var FIRST_KEY = /^([^\.]+)/; @@ -57,7 +60,7 @@ export function get(obj, keyName) { return obj; } - var meta = obj['__ember_meta__']; + var meta = peekMeta(obj); var possibleDesc = obj[keyName]; var desc = (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) ? possibleDesc : undefined; var ret;
true
Other
emberjs
ember.js
e46e056f1d5ed3136efbdf2136febebacd0461c6.json
use peekMeta + deleteMeta is isolate the code-base.
packages/ember-metal/lib/property_set.js
@@ -12,6 +12,9 @@ import { isPath, hasThis as pathHasThis } from 'ember-metal/path_cache'; +import { + peekMeta +} from 'ember-metal/meta'; /** Sets the value of a property on an object, respecting computed properties @@ -38,7 +41,7 @@ export function set(obj, keyName, value, tolerant) { var meta, possibleDesc, desc; if (obj) { - meta = obj['__ember_meta__']; + meta = peekMeta(obj); possibleDesc = obj[keyName]; desc = (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) ? possibleDesc : undefined; }
true
Other
emberjs
ember.js
e46e056f1d5ed3136efbdf2136febebacd0461c6.json
use peekMeta + deleteMeta is isolate the code-base.
packages/ember-metal/lib/watching.js
@@ -17,6 +17,10 @@ import { import { isPath } from 'ember-metal/path_cache'; +import { + peekMeta, + deleteMeta +} from 'ember-metal/meta'; /** Starts watching a property on an object. Whenever the property changes, @@ -45,7 +49,7 @@ function watch(obj, _keyPath, m) { export { watch }; export function isWatching(obj, key) { - var meta = obj['__ember_meta__']; + var meta = peekMeta(obj); return (meta && meta.peekWatching(key)) > 0; } @@ -75,11 +79,11 @@ var NODE_STACK = []; @private */ export function destroy(obj) { - var meta = obj['__ember_meta__']; + var meta = peekMeta(obj); var node, nodes, key, nodeObject; if (meta) { - obj['__ember_meta__'] = null; + deleteMeta(obj); // remove chainWatchers to remove circular references that would prevent GC node = meta.readableChains(); if (node) {
true
Other
emberjs
ember.js
e46e056f1d5ed3136efbdf2136febebacd0461c6.json
use peekMeta + deleteMeta is isolate the code-base.
packages/ember-metal/tests/chains_test.js
@@ -4,6 +4,8 @@ import { finishChains } from 'ember-metal/chains'; import { defineProperty } from 'ember-metal/properties'; import computed from 'ember-metal/computed'; import { propertyDidChange } from 'ember-metal/property_events'; +import { peekMeta } from 'ember-metal/meta'; + QUnit.module('Chains'); QUnit.test('finishChains should properly copy chains from prototypes to instances', function() { @@ -14,7 +16,7 @@ QUnit.test('finishChains should properly copy chains from prototypes to instance var childObj = Object.create(obj); finishChains(childObj); - ok(obj['__ember_meta__'].readableChains() !== childObj['__ember_meta__'].readableChains(), 'The chains object is copied'); + ok(peekMeta(obj) !== peekMeta(childObj).readableChains(), 'The chains object is copied'); });
true
Other
emberjs
ember.js
e46e056f1d5ed3136efbdf2136febebacd0461c6.json
use peekMeta + deleteMeta is isolate the code-base.
packages/ember-runtime/tests/system/object/destroy_test.js
@@ -9,7 +9,7 @@ import { } from 'ember-metal/property_events'; import { testBoth } from 'ember-metal/tests/props_helper'; import EmberObject from 'ember-runtime/system/object'; - +import { peekMeta } from 'ember-metal/meta'; QUnit.module('ember-runtime/system/object/destroy_test'); testBoth('should schedule objects to be destroyed at the end of the run loop', function(get, set) { @@ -18,13 +18,13 @@ testBoth('should schedule objects to be destroyed at the end of the run loop', f run(function() { obj.destroy(); - meta = obj['__ember_meta__']; + meta = peekMeta(obj); ok(meta, 'meta is not destroyed immediately'); ok(get(obj, 'isDestroying'), 'object is marked as destroying immediately'); ok(!get(obj, 'isDestroyed'), 'object is not destroyed immediately'); }); - meta = obj['__ember_meta__']; + meta = peekMeta(obj); ok(!meta, 'meta is destroyed after run loop finishes'); ok(get(obj, 'isDestroyed'), 'object is destroyed after run loop finishes'); });
true
Other
emberjs
ember.js
9851decd9919e2a3371eeaf4b65e8995980c5c2b.json
remove extra call to metaFor
packages/ember-metal/lib/mixin.js
@@ -378,7 +378,7 @@ function applyMixin(obj, mixins, partial) { // * Set up _super wrapping if necessary // * Set up computed property descriptors // * Copying `toString` in broken browsers - mergeMixins(mixins, metaFor(obj), descs, values, obj, keys); + mergeMixins(mixins, m, descs, values, obj, keys); for (var i = 0, l = keys.length; i < l; i++) { key = keys[i];
false
Other
emberjs
ember.js
6a6824860686ec8f18adc0fa739258f92df14cec.json
Add test for view controller changes
packages/ember-views/tests/views/view/controller_test.js
@@ -48,3 +48,45 @@ QUnit.test('controller property should be inherited from nearest ancestor with c grandchild.destroy(); }); }); + +QUnit.test('controller changes are passed to descendants', function() { + var grandparent = ContainerView.create(); + var parent = ContainerView.create(); + var child = ContainerView.create(); + var grandchild = ContainerView.create(); + + run(function() { + grandparent.set('controller', {}); + + grandparent.pushObject(parent); + parent.pushObject(child); + child.pushObject(grandchild); + }); + + var parentCount = 0; + var childCount = 0; + var grandchildCount = 0; + + parent.addObserver('controller', parent, function() { parentCount++; }); + child.addObserver('controller', child, function() { childCount++; }); + grandchild.addObserver('controller', grandchild, function() { grandchildCount++; }); + + run(function() { grandparent.set('controller', {}); }); + + equal(parentCount, 1); + equal(childCount, 1); + equal(grandchildCount, 1); + + run(function() { grandparent.set('controller', {}); }); + + equal(parentCount, 2); + equal(childCount, 2); + equal(grandchildCount, 2); + + run(function() { + grandparent.destroy(); + parent.destroy(); + child.destroy(); + grandchild.destroy(); + }); +});
false
Other
emberjs
ember.js
5fca89003b46eba529cc7d9e05cf8cb32451309e.json
Fix node tests to use new APIs
tests/node/helpers/app-module.js
@@ -87,11 +87,10 @@ module.exports = function(moduleName) { QUnit.module(moduleName, { beforeEach: function() { var Ember = this.Ember = require(emberPath); - var DOMHelper = Ember.HTMLBars.DOMHelper; + Ember.testing = true; this.compile = require(templateCompilerPath).compile; - this.domHelper = createDOMHelper(DOMHelper); this.run = Ember.run; this.all = Ember.RSVP.all; @@ -104,8 +103,22 @@ module.exports = function(moduleName) { this.view = registerView; this.routes = registerRoutes; this.registry = {}; - this.renderToElement = renderToElement; this.renderToHTML = renderToHTML; + + // TODO: REMOVE ME + + // Patch DOMHelper + Ember.HTMLBars.DOMHelper.prototype.zomg = "ZOMG"; + + Ember.HTMLBars.DOMHelper.prototype.protocolForURL = function(url) { + var protocol = URL.parse(url).protocol; + return (protocol == null) ? ':' : protocol; + }; + + Ember.HTMLBars.DOMHelper.prototype.setMorphHTML = function(morph, html) { + var section = this.document.createRawHTMLSection(html); + morph.setNode(section); + }; }, afterEach: function() { @@ -123,6 +136,8 @@ module.exports = function(moduleName) { module.exports.canRunTests = canRunTests; function createApplication() { + if (this.app) return this.app; + var app = this.Ember.Application.extend().create({ autoboot: false }); @@ -135,12 +150,11 @@ function createApplication() { app.Router.map(this.routesCallback); } - registerDOMHelper(this.Ember, app, this.domHelper); registerApplicationClasses(app, this.registry); - this.run(function() { - app.boot(); - }); + // Run application initializers + this.run(app, 'boot'); + this.app = app; return app; @@ -151,44 +165,32 @@ function register(containerKey, klass) { } function visit(url) { - if (!this.app) { this.createApplication(); } + var app = this.createApplication(); + var dom = new SimpleDOM.Document(); - var promise; - this.run(this, function() { - promise = this.app.visit(url); - }); - - return promise; -} - -function registerDOMHelper(Ember, app, domHelper) { - app.initializer({ - name: 'register-dom-helper', - initialize: function(app) { - app.register('renderer:-dom', { - create: function() { - return new Ember._Renderer(domHelper, false); - } - }); - } + return this.run(app, 'visit', url, { + isBrowser: false, + document: dom, + rootElement: dom.body }); } -function createDOMHelper(DOMHelper) { - var document = new SimpleDOM.Document(); - var domHelper = new DOMHelper(document); - - domHelper.protocolForURL = function(url) { - var protocol = URL.parse(url).protocol; - return (protocol == null) ? ':' : protocol; - }; - - domHelper.setMorphHTML = function(morph, html) { - var section = this.document.createRawHTMLSection(html); - morph.setNode(section); - }; +function renderToHTML(url) { + var app = this.createApplication(); + var dom = new SimpleDOM.Document(); + var root = dom.body; + + return this.run(app, 'visit', url, { + isBrowser: false, + document: dom, + rootElement: root + }).then(function() { + var element = root; + var serializer = new SimpleDOM.HTMLSerializer(SimpleDOM.voidMap); + var serialized = serializer.serialize(root); - return domHelper; + return serialized; + }); } function registerApplicationClasses(app, registry) { @@ -224,23 +226,3 @@ function registerView(name, viewProps) { function registerRoutes(cb) { this.routesCallback = cb; } - -function renderToElement(instance) { - var element; - this.run(function() { - element = instance.view.renderToElement(); - }); - - return element; -} - -function renderToHTML(route) { - var self = this; - return this.visit(route).then(function(instance) { - var element = self.renderToElement(instance); - var serializer = new SimpleDOM.HTMLSerializer(SimpleDOM.voidMap); - var serialized = serializer.serialize(element); - - return serialized; - }); -}
false
Other
emberjs
ember.js
20df8632b4361cb1b1d552e067084bbb9746888e.json
Avoid timing brittleness in Ember.Select test. The goal of this test is to ensure that the following scenario: 1. `selection` is set to a slow resolving promise 2. `selection` is set to another value (a promise that resolves before the "slow resolving" promise above) Results in the newest assigned selection (2. from above) and NOT the most recently resolved promise (1. from above). --- This test randomly fails in Sauce Labs in the previous rendition, because the VM sometimes runs slowly and the 10ms difference between the two `run.later`'s is lost.
packages/ember-views/tests/views/select_test.js
@@ -257,37 +257,36 @@ QUnit.test('selection can be set from a Promise when multiple=false', function() equal(select.$()[0].selectedIndex, 1, 'Should select from Promise content'); }); -QUnit.test('selection from a Promise don\'t overwrite newer selection once resolved, when multiple=false', function() { - expect(1); +QUnit.test('selection from a Promise don\'t overwrite newer selection once resolved, when multiple=false', function(assert) { + assert.expect(1); var yehuda = { id: 1, firstName: 'Yehuda' }; var tom = { id: 2, firstName: 'Tom' }; var seb = { id: 3, firstName: 'Seb' }; - QUnit.stop(); + let firstPromise = new RSVP.Promise(function(resolve) { + run.next(function() { + resolve(seb); + }); + }); + + let secondPromise = firstPromise.then(function() { + return tom; + }); run(function() { select.set('content', emberA([yehuda, tom, seb])); select.set('multiple', false); - select.set('selection', new RSVP.Promise(function(resolve, reject) { - run.later(function() { - run(function() { - resolve(tom); - }); - QUnit.start(); - equal(select.$()[0].selectedIndex, 2, 'Should not select from Promise if newer selection'); - }, 40); - })); - select.set('selection', new RSVP.Promise(function(resolve, reject) { - run.later(function() { - run(function() { - resolve(seb); - }); - }, 30); - })); + select.set('selection', secondPromise); + select.set('selection', firstPromise); }); append(); + + return RSVP.all([firstPromise, secondPromise]) + .then(() => { + assert.equal(select.$()[0].selectedIndex, 2, 'Should not select from Promise if newer selection'); + }); }); QUnit.test('selection from a Promise resolving to null should not select when multiple=false', function() {
false
Other
emberjs
ember.js
b0b4a1a96fe512c339d76082a181f2907012792f.json
Use promises for async tests
packages/ember-application/tests/system/visit_test.js
@@ -3,6 +3,7 @@ import EmberObject from 'ember-runtime/system/object'; import isEnabled from 'ember-metal/features'; import inject from 'ember-runtime/inject'; import run from 'ember-metal/run_loop'; +import { onerrorDefault } from 'ember-runtime/ext/rsvp'; import Application from 'ember-application/system/application'; import ApplicationInstance from 'ember-application/system/application-instance'; import Route from 'ember-routing/system/route'; @@ -51,9 +52,15 @@ function createApplication(integration) { return App; } +function expectAsyncError() { + Ember.RSVP.off('error'); +} + if (isEnabled('ember-application-visit')) { QUnit.module('Ember.Application - visit()', { teardown() { + Ember.RSVP.on('error', onerrorDefault); + if (instance) { run(instance, 'destroy'); instance = null; @@ -73,8 +80,9 @@ if (isEnabled('ember-application-visit')) { // instance initializer that would normally get called on DOM ready // does not fire. QUnit.test('Applications with autoboot set to false do not autoboot', function(assert) { - QUnit.expect(4); - QUnit.stop(); + function delay(time) { + return new Ember.RSVP.Promise(resolve => Ember.run.later(resolve, time)); + } let appBooted = 0; let instanceBooted = 0; @@ -98,33 +106,18 @@ if (isEnabled('ember-application-visit')) { }); // Continue after 500ms - setTimeout(function() { - QUnit.start(); - ok(appBooted === 0, '500ms elapsed without app being booted'); - ok(instanceBooted === 0, '500ms elapsed without instances being booted'); - - QUnit.stop(); - - run(function() { - App.boot().then( - () => { - QUnit.start(); - assert.ok(appBooted === 1, 'app should boot when manually calling `app.boot()`'); - assert.ok(instanceBooted === 0, 'no instances should be booted automatically when manually calling `app.boot()'); - }, - (error) => { - QUnit.start(); - assert.ok(false, 'the boot process failed with ' + error); - } - ); - }); - }, 500); + return delay(500).then(() => { + assert.ok(appBooted === 0, '500ms elapsed without app being booted'); + assert.ok(instanceBooted === 0, '500ms elapsed without instances being booted'); + + return run(App, 'boot'); + }).then(() => { + assert.ok(appBooted === 1, 'app should boot when manually calling `app.boot()`'); + assert.ok(instanceBooted === 0, 'no instances should be booted automatically when manually calling `app.boot()'); + }); }); QUnit.test('calling visit() on app without first calling boot() should boot the app', function(assert) { - QUnit.expect(2); - QUnit.stop(); - let appBooted = 0; let instanceBooted = 0; @@ -144,25 +137,15 @@ if (isEnabled('ember-application-visit')) { instanceBooted++; } }); + }); - App.visit('/').then( - () => { - QUnit.start(); - assert.ok(appBooted === 1, 'the app should be booted`'); - assert.ok(instanceBooted === 1, 'an instances should be booted'); - }, - (error) => { - QUnit.start(); - assert.ok(false, 'the boot process failed with ' + error); - } - ); + return run(App, 'visit', '/').then(() => { + assert.ok(appBooted === 1, 'the app should be booted`'); + assert.ok(instanceBooted === 1, 'an instances should be booted'); }); }); QUnit.test('calling visit() on an already booted app should not boot it again', function(assert) { - QUnit.expect(6); - QUnit.stop(); - let appBooted = 0; let instanceBooted = 0; @@ -182,36 +165,25 @@ if (isEnabled('ember-application-visit')) { instanceBooted++; } }); + }); - App.boot().then(() => { - QUnit.start(); - assert.ok(appBooted === 1, 'the app should be booted'); - assert.ok(instanceBooted === 0, 'no instances should be booted'); - QUnit.stop(); - - return App.visit('/'); - }).then(() => { - QUnit.start(); - assert.ok(appBooted === 1, 'the app should not be booted again'); - assert.ok(instanceBooted === 1, 'an instance should be booted'); - QUnit.stop(); - - return App.visit('/'); - }).then(() => { - QUnit.start(); - assert.ok(appBooted === 1, 'the app should not be booted again'); - assert.ok(instanceBooted === 2, 'another instance should be booted'); - }).catch((error) => { - QUnit.start(); - assert.ok(false, 'the boot process failed with ' + error); - }); + return run(App, 'boot').then(() => { + assert.ok(appBooted === 1, 'the app should be booted'); + assert.ok(instanceBooted === 0, 'no instances should be booted'); + + return run(App, 'visit', '/'); + }).then(() => { + assert.ok(appBooted === 1, 'the app should not be booted again'); + assert.ok(instanceBooted === 1, 'an instance should be booted'); + + return run(App, 'visit', '/'); + }).then(() => { + assert.ok(appBooted === 1, 'the app should not be booted again'); + assert.ok(instanceBooted === 2, 'another instance should be booted'); }); }); QUnit.test('visit() rejects on application boot failure', function(assert) { - QUnit.expect(2); - QUnit.stop(); - run(function() { createApplication(); @@ -221,25 +193,19 @@ if (isEnabled('ember-application-visit')) { throw new Error('boot failure'); } }); + }); - App.visit('/').then( - () => { - QUnit.start(); - assert.ok(false, 'It should not resolve the promise'); - }, - (error) => { - QUnit.start(); - assert.ok(error instanceof Error, 'It should reject the promise with the boot error'); - assert.equal(error.message, 'boot failure'); - } - ); + expectAsyncError(); + + return run(App, 'visit', '/').then(() => { + assert.ok(false, 'It should not resolve the promise'); + }, error => { + assert.ok(error instanceof Error, 'It should reject the promise with the boot error'); + assert.equal(error.message, 'boot failure'); }); }); QUnit.test('visit() rejects on instance boot failure', function(assert) { - QUnit.expect(2); - QUnit.stop(); - run(function() { createApplication(); @@ -249,25 +215,19 @@ if (isEnabled('ember-application-visit')) { throw new Error('boot failure'); } }); + }); - App.visit('/').then( - () => { - QUnit.start(); - assert.ok(false, 'It should not resolve the promise'); - }, - (error) => { - QUnit.start(); - assert.ok(error instanceof Error, 'It should reject the promise with the boot error'); - assert.equal(error.message, 'boot failure'); - } - ); + expectAsyncError(); + + return run(App, 'visit', '/').then(() => { + assert.ok(false, 'It should not resolve the promise'); + }, error => { + assert.ok(error instanceof Error, 'It should reject the promise with the boot error'); + assert.equal(error.message, 'boot failure'); }); }); QUnit.test('visit() follows redirects', function(assert) { - QUnit.expect(2); - QUnit.stop(); - run(function() { createApplication(); @@ -288,25 +248,15 @@ if (isEnabled('ember-application-visit')) { this.transitionTo('c', params.b); } })); + }); - App.visit('/a').then( - (instance) => { - QUnit.start(); - assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); - assert.equal(instance.getURL(), '/c/zomg', 'It should follow all redirects'); - }, - (error) => { - QUnit.start(); - assert.ok(false, 'The visit() promise was rejected: ' + error); - } - ); + return run(App, 'visit', '/a').then(instance => { + assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); + assert.equal(instance.getURL(), '/c/zomg', 'It should follow all redirects'); }); }); QUnit.test('visit() rejects if an error occured during a transition', function(assert) { - QUnit.expect(2); - QUnit.stop(); - run(function() { createApplication(); @@ -333,25 +283,19 @@ if (isEnabled('ember-application-visit')) { throw new Error('transition failure'); } })); + }); - App.visit('/a').then( - () => { - QUnit.start(); - assert.ok(false, 'It should not resolve the promise'); - }, - (error) => { - QUnit.start(); - assert.ok(error instanceof Error, 'It should reject the promise with the boot error'); - assert.equal(error.message, 'transition failure'); - } - ); + expectAsyncError(); + + return run(App, 'visit', '/a').then(() => { + assert.ok(false, 'It should not resolve the promise'); + }, error => { + assert.ok(error instanceof Error, 'It should reject the promise with the boot error'); + assert.equal(error.message, 'transition failure'); }); }); QUnit.test('visit() chain', function(assert) { - QUnit.expect(8); - QUnit.stop(); - run(function() { createApplication(); @@ -360,43 +304,30 @@ if (isEnabled('ember-application-visit')) { this.route('b'); this.route('c'); }); + }); - App.visit('/').then((instance) => { - QUnit.start(); - assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); - assert.equal(instance.getURL(), '/'); - - QUnit.stop(); - return instance.visit('/a'); - }).then((instance) => { - QUnit.start(); - assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); - assert.equal(instance.getURL(), '/a'); - - QUnit.stop(); - return instance.visit('/b'); - }).then((instance) => { - QUnit.start(); - assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); - assert.equal(instance.getURL(), '/b'); - - QUnit.stop(); - return instance.visit('/c'); - }).then((instance) => { - QUnit.start(); - assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); - assert.equal(instance.getURL(), '/c'); - }).catch((error) => { - QUnit.start(); - assert.ok(false, 'The visit() promise was rejected: ' + error); - }); + return run(App, 'visit', '/').then(instance => { + assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); + assert.equal(instance.getURL(), '/'); + + return instance.visit('/a'); + }).then(instance => { + assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); + assert.equal(instance.getURL(), '/a'); + + return instance.visit('/b'); + }).then(instance => { + assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); + assert.equal(instance.getURL(), '/b'); + + return instance.visit('/c'); + }).then(instance => { + assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); + assert.equal(instance.getURL(), '/c'); }); }); QUnit.test('visit() returns a promise that resolves when the view has rendered', function(assert) { - QUnit.expect(3); - QUnit.stop(); - run(function() { createApplication(); @@ -405,22 +336,13 @@ if (isEnabled('ember-application-visit')) { assert.strictEqual(Ember.$('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element'); - run(function() { - App.visit('/').then(function(instance) { - QUnit.start(); - assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); - assert.equal(Ember.$('#qunit-fixture > .ember-view h1').text(), 'Hello world', 'the application was rendered once the promise resolves'); - }, function(error) { - QUnit.start(); - assert.ok(false, 'The visit() promise was rejected: ' + error); - }); + return run(App, 'visit', '/').then(instance => { + assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); + assert.equal(Ember.$('#qunit-fixture > .ember-view h1').text(), 'Hello world', 'the application was rendered once the promise resolves'); }); }); QUnit.test('Views created via visit() are not added to the global views hash', function(assert) { - QUnit.expect(6); - QUnit.stop(); - run(function() { createApplication(); @@ -437,27 +359,21 @@ if (isEnabled('ember-application-visit')) { assert.strictEqual(Ember.$('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element'); - run(function() { - App.visit('/').then(function(instance) { - QUnit.start(); - assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); - assert.equal(Ember.$('#qunit-fixture > #my-cool-app h1').text(), 'Hello world', 'the application was rendered once the promise resolves'); - assert.strictEqual(View.views['my-cool-app'], undefined, 'view was not registered globally'); - - function lookup(fullName) { - if (isEnabled('ember-registry-container-reform')) { - return instance.lookup(fullName); - } else { - return instance.container.lookup(fullName); - } + return run(App, 'visit', '/').then(instance => { + assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); + assert.equal(Ember.$('#qunit-fixture > #my-cool-app h1').text(), 'Hello world', 'the application was rendered once the promise resolves'); + assert.strictEqual(View.views['my-cool-app'], undefined, 'view was not registered globally'); + + function lookup(fullName) { + if (isEnabled('ember-registry-container-reform')) { + return instance.lookup(fullName); + } else { + return instance.container.lookup(fullName); } + } - assert.ok(lookup('-view-registry:main')['my-cool-app'] instanceof View, 'view was registered on the instance\'s view registry'); - assert.ok(lookup('-view-registry:main')['child-view'] instanceof View, 'child view was registered on the instance\'s view registry'); - }, function(error) { - QUnit.start(); - assert.ok(false, 'The visit() promise was rejected: ' + error); - }); + assert.ok(lookup('-view-registry:main')['my-cool-app'] instanceof View, 'view was registered on the instance\'s view registry'); + assert.ok(lookup('-view-registry:main')['child-view'] instanceof View, 'child view was registered on the instance\'s view registry'); }); }); @@ -475,99 +391,95 @@ if (isEnabled('ember-application-visit')) { } }); - QUnit.test('FastBoot-style setup', function(assert) { - QUnit.expect(15); - QUnit.stop(); + if (document.implementation && typeof document.implementation.createHTMLDocument === 'function') { + QUnit.test('FastBoot-style setup', function(assert) { + let initCalled = false; + let didInsertElementCalled = false; - let initCalled = false; - let didInsertElementCalled = false; - - run(function() { - createApplication(true); + run(function() { + createApplication(true); - App.Router.map(function() { - this.route('a'); - this.route('b'); - }); + App.Router.map(function() { + this.route('a'); + this.route('b'); + }); - App.register('template:application', compile('<h1>Hello world</h1>\n{{outlet}}')); + App.register('template:application', compile('<h1>Hello world</h1>\n{{outlet}}')); - App.register('template:a', compile('<h2>Welcome to {{x-foo page="A"}}</h2>')); + App.register('template:a', compile('<h2>Welcome to {{x-foo page="A"}}</h2>')); - App.register('template:b', compile('<h2>{{x-foo page="B"}}</h2>')); + App.register('template:b', compile('<h2>{{x-foo page="B"}}</h2>')); - App.register('template:components/x-foo', compile('Page {{page}}')); + App.register('template:components/x-foo', compile('Page {{page}}')); - App.register('component:x-foo', Component.extend({ - tagName: 'span', - init() { - this._super(); - initCalled = true; - }, - didInsertElement() { - didInsertElementCalled = true; - } - })); - }); + App.register('component:x-foo', Component.extend({ + tagName: 'span', + init() { + this._super(); + initCalled = true; + }, + didInsertElement() { + didInsertElementCalled = true; + } + })); + }); - assert.strictEqual(Ember.$('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element'); + assert.strictEqual(Ember.$('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element'); - function makeFakeDom() { - // TODO: use simple-dom - return document.implementation.createHTMLDocument(); - } + function makeForiegnDocument() { + // TODO: use simple-dom + return document.implementation.createHTMLDocument(); + } - let a = run(function() { - let dom = makeFakeDom(); + let a = run(function() { + let dom = makeForiegnDocument(); - return App.visit('/a', { isBrowser: false, document: dom, rootElement: dom.body }).then(instance => { - QUnit.start(); - assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); - assert.equal(instance.getURL(), '/a'); + return App.visit('/a', { isBrowser: false, document: dom, rootElement: dom.body }).then(instance => { + QUnit.start(); + assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); + assert.equal(instance.getURL(), '/a'); - let serialized = dom.body.innerHTML; - let $parsed = Ember.$(serialized); + let serialized = dom.body.innerHTML; + let $parsed = Ember.$(serialized); - assert.equal($parsed.find('h1').text(), 'Hello world'); - assert.equal($parsed.find('h2').text(), 'Welcome to Page A'); + assert.equal($parsed.find('h1').text(), 'Hello world'); + assert.equal($parsed.find('h2').text(), 'Welcome to Page A'); - assert.ok(initCalled, 'Component#init should be called'); - assert.ok(!didInsertElementCalled, 'Component#didInsertElement should not be called'); + assert.ok(initCalled, 'Component#init should be called'); + assert.ok(!didInsertElementCalled, 'Component#didInsertElement should not be called'); - assert.strictEqual(Ember.$('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element'); - QUnit.stop(); + assert.strictEqual(Ember.$('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element'); + QUnit.stop(); + }); }); - }); - let b = run(function() { - let dom = makeFakeDom(); + let b = run(function() { + let dom = makeForiegnDocument(); - return App.visit('/b', { isBrowser: false, document: dom, rootElement: dom.body }).then(instance => { - QUnit.start(); - assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); - assert.equal(instance.getURL(), '/b'); + return App.visit('/b', { isBrowser: false, document: dom, rootElement: dom.body }).then(instance => { + QUnit.start(); + assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); + assert.equal(instance.getURL(), '/b'); - let serialized = dom.body.innerHTML; - let $parsed = Ember.$(serialized); + let serialized = dom.body.innerHTML; + let $parsed = Ember.$(serialized); - assert.equal($parsed.find('h1').text(), 'Hello world'); - assert.equal($parsed.find('h2').text(), 'Page B'); + assert.equal($parsed.find('h1').text(), 'Hello world'); + assert.equal($parsed.find('h2').text(), 'Page B'); - assert.ok(initCalled, 'Component#init should be called'); - assert.ok(!didInsertElementCalled, 'Component#didInsertElement should not be called'); + assert.ok(initCalled, 'Component#init should be called'); + assert.ok(!didInsertElementCalled, 'Component#didInsertElement should not be called'); - assert.strictEqual(Ember.$('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element'); - QUnit.stop(); + assert.strictEqual(Ember.$('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element'); + QUnit.stop(); + }); }); - }); - Ember.RSVP.all([a, b]).finally(() => QUnit.start()); - }); + return Ember.RSVP.all([a, b]); + }); + } QUnit.test('Ember Islands-style setup', function(assert) { - QUnit.expect(14); - QUnit.stop(); - let xFooInitCalled = false; let xFooDidInsertElementCalled = false; @@ -662,49 +574,43 @@ if (isEnabled('ember-application-visit')) { let $bar = Ember.$('<div />').appendTo('#qunit-fixture'); let data = encodeURIComponent(JSON.stringify({ name: 'Godfrey' })); - run(function() { - Ember.RSVP.all([ - App.visit(`/x-foo?data=${data}`, { rootElement: $foo[0] }), - App.visit('/x-bar', { rootElement: $bar[0] }) - ]).then(() => { - QUnit.start(); - - assert.ok(xFooInitCalled); - assert.ok(xFooDidInsertElementCalled); - assert.ok(xBarInitCalled); - assert.ok(xBarDidInsertElementCalled); + return Ember.RSVP.all([ + run(App, 'visit', `/x-foo?data=${data}`, { rootElement: $foo[0] }), + run(App, 'visit', '/x-bar', { rootElement: $bar[0] }) + ]).then(() => { + assert.ok(xFooInitCalled); + assert.ok(xFooDidInsertElementCalled); - assert.equal($foo.find('h1').text(), 'X-Foo'); - assert.equal($foo.find('p').text(), 'Hello Godfrey, I have been clicked 0 times (0 times combined)!'); - assert.ok($foo.text().indexOf('X-Bar') === -1); + assert.ok(xBarInitCalled); + assert.ok(xBarDidInsertElementCalled); - assert.equal($bar.find('h1').text(), 'X-Bar'); - assert.equal($bar.find('button').text(), 'Join 0 others in clicking me!'); - assert.ok($bar.text().indexOf('X-Foo') === -1); + assert.equal($foo.find('h1').text(), 'X-Foo'); + assert.equal($foo.find('p').text(), 'Hello Godfrey, I have been clicked 0 times (0 times combined)!'); + assert.ok($foo.text().indexOf('X-Bar') === -1); - run(function() { - $foo.find('x-foo').click(); - }); + assert.equal($bar.find('h1').text(), 'X-Bar'); + assert.equal($bar.find('button').text(), 'Join 0 others in clicking me!'); + assert.ok($bar.text().indexOf('X-Foo') === -1); - assert.equal($foo.find('p').text(), 'Hello Godfrey, I have been clicked 1 times (1 times combined)!'); - assert.equal($bar.find('button').text(), 'Join 1 others in clicking me!'); + run(function() { + $foo.find('x-foo').click(); + }); - run(function() { - $bar.find('button').click(); - $bar.find('button').click(); - }); + assert.equal($foo.find('p').text(), 'Hello Godfrey, I have been clicked 1 times (1 times combined)!'); + assert.equal($bar.find('button').text(), 'Join 1 others in clicking me!'); - assert.equal($foo.find('p').text(), 'Hello Godfrey, I have been clicked 1 times (3 times combined)!'); - assert.equal($bar.find('button').text(), 'Join 3 others in clicking me!'); + run(function() { + $bar.find('button').click(); + $bar.find('button').click(); }); + + assert.equal($foo.find('p').text(), 'Hello Godfrey, I have been clicked 1 times (3 times combined)!'); + assert.equal($bar.find('button').text(), 'Join 3 others in clicking me!'); }); }); QUnit.test('Resource-discovery setup', function(assert) { - QUnit.expect(26); - QUnit.stop(); - let xFooInstances = 0; run(function() { @@ -780,92 +686,72 @@ if (isEnabled('ember-application-visit')) { } } - let a = run(function() { - return App.visit('/a', { isBrowser: false, shouldRender: false }).then((instance) => { - QUnit.start(); - assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); + let a = run(App, 'visit', '/a', { isBrowser: false, shouldRender: false }).then(instance => { + assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); - assert.strictEqual(Ember.$('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element'); - assert.strictEqual(xFooInstances, 0, 'did not create any x-foo components'); + assert.strictEqual(Ember.$('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element'); + assert.strictEqual(xFooInstances, 0, 'did not create any x-foo components'); - let viewRegistry = lookup(instance, '-view-registry:main'); - assert.strictEqual(Object.keys(viewRegistry).length, 0, 'did not create any views'); + let viewRegistry = lookup(instance, '-view-registry:main'); + assert.strictEqual(Object.keys(viewRegistry).length, 0, 'did not create any views'); - let networkService = lookup(instance, 'service:network'); - assert.deepEqual(networkService.get('requests'), ['/a', '/b', '/c']); - QUnit.stop(); - }); + let networkService = lookup(instance, 'service:network'); + assert.deepEqual(networkService.get('requests'), ['/a', '/b', '/c']); }); - let b = run(function() { - return App.visit('/b', { isBrowser: false, shouldRender: false }).then((instance) => { - QUnit.start(); - assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); + let b = run(App, 'visit', '/b', { isBrowser: false, shouldRender: false }).then(instance => { + assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); - assert.strictEqual(Ember.$('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element'); - assert.strictEqual(xFooInstances, 0, 'did not create any x-foo components'); + assert.strictEqual(Ember.$('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element'); + assert.strictEqual(xFooInstances, 0, 'did not create any x-foo components'); - let viewRegistry = lookup(instance, '-view-registry:main'); - assert.strictEqual(Object.keys(viewRegistry).length, 0, 'did not create any views'); + let viewRegistry = lookup(instance, '-view-registry:main'); + assert.strictEqual(Object.keys(viewRegistry).length, 0, 'did not create any views'); - let networkService = lookup(instance, 'service:network'); - assert.deepEqual(networkService.get('requests'), ['/b', '/c']); - QUnit.stop(); - }); + let networkService = lookup(instance, 'service:network'); + assert.deepEqual(networkService.get('requests'), ['/b', '/c']); }); - let c = run(function() { - return App.visit('/c', { isBrowser: false, shouldRender: false }).then((instance) => { - QUnit.start(); - assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); + let c = run(App, 'visit', '/c', { isBrowser: false, shouldRender: false }).then(instance => { + assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); - assert.strictEqual(Ember.$('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element'); - assert.strictEqual(xFooInstances, 0, 'did not create any x-foo components'); + assert.strictEqual(Ember.$('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element'); + assert.strictEqual(xFooInstances, 0, 'did not create any x-foo components'); - let viewRegistry = lookup(instance, '-view-registry:main'); - assert.strictEqual(Object.keys(viewRegistry).length, 0, 'did not create any views'); + let viewRegistry = lookup(instance, '-view-registry:main'); + assert.strictEqual(Object.keys(viewRegistry).length, 0, 'did not create any views'); - let networkService = lookup(instance, 'service:network'); - assert.deepEqual(networkService.get('requests'), ['/c']); - QUnit.stop(); - }); + let networkService = lookup(instance, 'service:network'); + assert.deepEqual(networkService.get('requests'), ['/c']); }); - let d = run(function() { - return App.visit('/d', { isBrowser: false, shouldRender: false }).then((instance) => { - QUnit.start(); - assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); + let d = run(App, 'visit', '/d', { isBrowser: false, shouldRender: false }).then(instance => { + assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); - assert.strictEqual(Ember.$('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element'); - assert.strictEqual(xFooInstances, 0, 'did not create any x-foo components'); + assert.strictEqual(Ember.$('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element'); + assert.strictEqual(xFooInstances, 0, 'did not create any x-foo components'); - let viewRegistry = lookup(instance, '-view-registry:main'); - assert.strictEqual(Object.keys(viewRegistry).length, 0, 'did not create any views'); + let viewRegistry = lookup(instance, '-view-registry:main'); + assert.strictEqual(Object.keys(viewRegistry).length, 0, 'did not create any views'); - let networkService = lookup(instance, 'service:network'); - assert.deepEqual(networkService.get('requests'), ['/d', '/e']); - QUnit.stop(); - }); + let networkService = lookup(instance, 'service:network'); + assert.deepEqual(networkService.get('requests'), ['/d', '/e']); }); - let e = run(function() { - return App.visit('/e', { isBrowser: false, shouldRender: false }).then((instance) => { - QUnit.start(); - assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); + let e = run(App, 'visit', '/e', { isBrowser: false, shouldRender: false }).then(instance => { + assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); - assert.strictEqual(Ember.$('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element'); - assert.strictEqual(xFooInstances, 0, 'did not create any x-foo components'); + assert.strictEqual(Ember.$('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element'); + assert.strictEqual(xFooInstances, 0, 'did not create any x-foo components'); - let viewRegistry = lookup(instance, '-view-registry:main'); - assert.strictEqual(Object.keys(viewRegistry).length, 0, 'did not create any views'); + let viewRegistry = lookup(instance, '-view-registry:main'); + assert.strictEqual(Object.keys(viewRegistry).length, 0, 'did not create any views'); - let networkService = lookup(instance, 'service:network'); - assert.deepEqual(networkService.get('requests'), ['/e']); - QUnit.stop(); - }); + let networkService = lookup(instance, 'service:network'); + assert.deepEqual(networkService.get('requests'), ['/e']); }); - Ember.RSVP.all([a, b, c, d, e]).finally(() => QUnit.start()); + return Ember.RSVP.all([a, b, c, d, e]); }); QUnit.skip('Test setup', function(assert) {
false
Other
emberjs
ember.js
01fc2a683a92ddf5d069a33eb92f6af2c37582c2.json
Prefix boolean flags w/Java conventions
packages/ember-application/lib/system/application-instance.js
@@ -167,7 +167,7 @@ let ApplicationInstance = EmberObject.extend(RegistryProxy, ContainerProxy, { registry.register('renderer:-dom', { create() { - return new Renderer(new DOMHelper(options.document), options.interactive); + return new Renderer(new DOMHelper(options.document), options.isInteractive); } }); @@ -184,7 +184,7 @@ let ApplicationInstance = EmberObject.extend(RegistryProxy, ContainerProxy, { this.application.runInstanceInitializers(this); - if (options.interactive) { + if (options.isInteractive) { this.setupEventDispatcher(); } } else { @@ -383,18 +383,18 @@ if (isEnabled('ember-application-visit')) { @default auto-detected @private */ - this.jQuery = jQuery; + this.jQuery = jQuery; // This default is overridable below /** Interactive mode: whether we need to set up event delegation and invoke lifecycle callbacks on Components. - @property interactive + @property isInteractive @type boolean @default auto-detected @private */ - this.interactive = environment.hasDOM; + this.isInteractive = environment.hasDOM; // This default is overridable below /** Run in a full browser environment. @@ -415,20 +415,20 @@ if (isEnabled('ember-application-visit')) { the location adapter specified in the app's router instead, you can also specify `{ location: null }` to specifically opt-out.) - @property browser + @property isBrowser @type boolean @default auto-detected @public */ - if (options.browser !== undefined) { - this.browser = !!options.browser; + if (options.isBrowser !== undefined) { + this.isBrowser = !!options.isBrowser; } else { - this.browser = environment.hasDOM; + this.isBrowser = environment.hasDOM; } - if (!this.browser) { + if (!this.isBrowser) { this.jQuery = null; - this.interactive = false; + this.isInteractive = false; this.location = 'none'; } @@ -439,20 +439,20 @@ if (isEnabled('ember-application-visit')) { pipeline. Essentially, this puts the app into "routing-only" mode. No templates will be rendered, and no Components will be created. - @property render + @property shouldRender @type boolean @default true @public */ - if (options.render !== undefined) { - this.render = !!options.render; + if (options.shouldRender !== undefined) { + this.shouldRender = !!options.shouldRender; } else { - this.render = true; + this.shouldRender = true; } - if (!this.render) { + if (!this.shouldRender) { this.jQuery = null; - this.interactive = false; + this.isInteractive = false; } /** @@ -503,6 +503,10 @@ if (isEnabled('ember-application-visit')) { this.rootElement = options.rootElement; } + // Set these options last to give the user a chance to override the + // defaults from the "combo" options like `isBrowser` (although in + // practice, the resulting combination is probably invalid) + /** If present, overrides the router's `location` property with this value. This is useful for environments where trying to modify the @@ -521,8 +525,8 @@ if (isEnabled('ember-application-visit')) { this.jQuery = options.jQuery; } - if (options.interactive !== undefined) { - this.interactive = !!options.interactive; + if (options.isInteractive !== undefined) { + this.isInteractive = !!options.isInteractive; } };
true
Other
emberjs
ember.js
01fc2a683a92ddf5d069a33eb92f6af2c37582c2.json
Prefix boolean flags w/Java conventions
packages/ember-application/lib/system/application.js
@@ -373,8 +373,7 @@ var Application = Namespace.extend(RegistryProxy, { } else { // Force-assign these flags to their default values when the feature is // disabled, this ensures we can rely on their values in other paths. - this.autoboot = true; - this._globalsMode = true; + this.autoboot = this._globalsMode = true; } if (this._globalsMode) { @@ -999,18 +998,16 @@ if (isEnabled('ember-application-visit')) { MyApp.visit("/", { location: "none", rootElement: "#container" }); ``` - All options are optional. - ### Supported Scenarios While the `BootOptions` class exposes a large number of knobs, not all combinations of them are valid; certain incompatible combinations might result in unexpected behavior. For example, booting the instance in the full browser environment - while specifying a foriegn `document` object (e.g. - `{ browser: true, document: iframe.contentDocument }`) does not work - correctly today, largely due to Ember's jQuery dependency. + while specifying a foriegn `document` object (e.g. `{ isBrowser: true, + document: iframe.contentDocument }`) does not work correctly today, + largely due to Ember's jQuery dependency. Currently, there are three officially supported scenarios/configurations. Usages outside of these scenarios are not guaranteed to work, but please @@ -1059,7 +1056,7 @@ if (isEnabled('ember-application-visit')) { let sessionId = MyApp.generateSessionID(); let player1 = App.visit(`/matches/join?name=Player+1&session=${sessionId}`, { rootElement: '#left', location: 'none' }); - let player2 = App.visit(`/matches/join?name=Player+2&session=${sessionId}`, { rootElement: '#left', location: 'none' }); + let player2 = App.visit(`/matches/join?name=Player+2&session=${sessionId}`, { rootElement: '#right', location: 'none' }); Promise.all([player1, player2]).then(() => { // Both apps have completed the initial render @@ -1082,7 +1079,7 @@ if (isEnabled('ember-application-visit')) { function renderURL(url) { let dom = new SimpleDOM.Document(); let rootElement = dom.body; - let options = { browser: false, document: dom, rootElement: rootElement }; + let options = { isBrowser: false, document: dom, rootElement: rootElement }; return MyApp.visit(options).then(instance => { try { @@ -1104,7 +1101,7 @@ if (isEnabled('ember-application-visit')) { specify a DOM `Element` object in the same `document` for the `rootElement` option (as opposed to a selector string like `"body"`). - See the documentation on the `browser`, `document` and `rootElement` properties + See the documentation on the `isBrowser`, `document` and `rootElement` properties on `Ember.ApplicationInstance.BootOptions` for details. #### Server-Side Resource Discovery @@ -1118,6 +1115,11 @@ if (isEnabled('ember-application-visit')) { import BrowserNetworkService from 'app/services/network/browser'; import NodeNetworkService from 'app/services/network/node'; + // Inject a (hypothetical) service for abstracting all AJAX calls and use + // the appropiate implementaion on the client/server. This also allows the + // server to log all the AJAX calls made during a particular request and use + // that for resource-discovery purpose. + export function initialize(application) { if (window) { // browser application.register('service:network', BrowserNetworkService); @@ -1135,6 +1137,10 @@ if (isEnabled('ember-application-visit')) { ``` ```app/routes/post.js + import Ember from 'ember'; + + // An example of how the (hypothetical) service is used in routes. + export default Ember.Route.extend({ model(params) { return this.network.fetch(`/api/posts/${params.post_id}.json`); @@ -1151,8 +1157,10 @@ if (isEnabled('ember-application-visit')) { ``` ```javascript + // Finally, put all the pieces together + function discoverResourcesFor(url) { - return MyApp.visit(options).then(instance => { + return MyApp.visit(url, { isBrowser: false, shouldRender: false }).then(instance => { let networkService = instance.lookup('service:network'); return networkService.requests; // => { "/api/posts/123.json": "..." } });
true
Other
emberjs
ember.js
01fc2a683a92ddf5d069a33eb92f6af2c37582c2.json
Prefix boolean flags w/Java conventions
packages/ember-application/tests/system/visit_test.js
@@ -520,7 +520,7 @@ if (isEnabled('ember-application-visit')) { let a = run(function() { let dom = makeFakeDom(); - return App.visit('/a', { browser: false, document: dom, rootElement: dom.body }).then(instance => { + return App.visit('/a', { isBrowser: false, document: dom, rootElement: dom.body }).then(instance => { QUnit.start(); assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); assert.equal(instance.getURL(), '/a'); @@ -542,7 +542,7 @@ if (isEnabled('ember-application-visit')) { let b = run(function() { let dom = makeFakeDom(); - return App.visit('/b', { browser: false, document: dom, rootElement: dom.body }).then(instance => { + return App.visit('/b', { isBrowser: false, document: dom, rootElement: dom.body }).then(instance => { QUnit.start(); assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); assert.equal(instance.getURL(), '/b'); @@ -781,7 +781,7 @@ if (isEnabled('ember-application-visit')) { } let a = run(function() { - return App.visit('/a', { browser: false, render: false }).then((instance) => { + return App.visit('/a', { isBrowser: false, shouldRender: false }).then((instance) => { QUnit.start(); assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); @@ -798,7 +798,7 @@ if (isEnabled('ember-application-visit')) { }); let b = run(function() { - return App.visit('/b', { browser: false, render: false }).then((instance) => { + return App.visit('/b', { isBrowser: false, shouldRender: false }).then((instance) => { QUnit.start(); assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); @@ -815,7 +815,7 @@ if (isEnabled('ember-application-visit')) { }); let c = run(function() { - return App.visit('/c', { browser: false, render: false }).then((instance) => { + return App.visit('/c', { isBrowser: false, shouldRender: false }).then((instance) => { QUnit.start(); assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); @@ -832,7 +832,7 @@ if (isEnabled('ember-application-visit')) { }); let d = run(function() { - return App.visit('/d', { browser: false, render: false }).then((instance) => { + return App.visit('/d', { isBrowser: false, shouldRender: false }).then((instance) => { QUnit.start(); assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); @@ -849,7 +849,7 @@ if (isEnabled('ember-application-visit')) { }); let e = run(function() { - return App.visit('/e', { browser: false, render: false }).then((instance) => { + return App.visit('/e', { isBrowser: false, shouldRender: false }).then((instance) => { QUnit.start(); assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance');
true
Other
emberjs
ember.js
01fc2a683a92ddf5d069a33eb92f6af2c37582c2.json
Prefix boolean flags w/Java conventions
packages/ember-routing/lib/system/route.js
@@ -1214,7 +1214,7 @@ var Route = EmberObject.extend(ActionHandler, Evented, { this.setupController(controller, context, transition); if (isEnabled('ember-application-visit')) { - if (!this._environment || this._environment.options.render) { + if (!this._environment || this._environment.options.shouldRender) { this.renderTemplate(controller, context); } } else {
true
Other
emberjs
ember.js
551d6fc1dd983594831bdf8d716291ac4a86255c.json
Fix all the typos
packages/ember-application/lib/system/application-instance.js
@@ -150,7 +150,7 @@ let ApplicationInstance = EmberObject.extend(RegistryProxy, ContainerProxy, { We would like new code (like the `visit` API) to stop making this assumption, so we created the asynchronous version above that returns a promise. But until we have migrated all the code, we would have to expose this method for use - *internall* in places where we need to boot an instance synchronously. + *internally* in places where we need to boot an instance synchronously. @private */ @@ -374,7 +374,7 @@ if (isEnabled('ember-application-visit')) { /** Provide a specific instance of jQuery. This is useful in conjunction with the `document` option, as it allows you to use a copy of `jQuery` that is - appropiately bound to the foriegn `document` (e.g. a jsdom). + appropriately bound to the foreign `document` (e.g. a jsdom). This is highly experimental and support very incomplete at the moment. @@ -403,7 +403,7 @@ if (isEnabled('ember-application-visit')) { and interactive features. Specifically: * It does not use `jQuery` to append the root view; the `rootElement` - (either specified as a subsequent option or on the applicatio itself) + (either specified as a subsequent option or on the application itself) must already be an `Element` in the given `document` (as opposed to a string selector).
true
Other
emberjs
ember.js
551d6fc1dd983594831bdf8d716291ac4a86255c.json
Fix all the typos
packages/ember-application/lib/system/application.js
@@ -308,7 +308,7 @@ var Application = Namespace.extend(RegistryProxy, { /** Whether the application should be configured for the legacy "globals mode". - Under this mode, the Application object serves as a gobal namespace for all + Under this mode, the Application object serves as a global namespace for all classes. ```javascript @@ -329,15 +329,15 @@ var Application = Namespace.extend(RegistryProxy, { }); ``` - This flag also exposes other internal APIs that assumes the existance of + This flag also exposes other internal APIs that assumes the existence of a special "default instance", like `App.__container__.lookup(...)`. This option is currently not configurable, its value is derived from the `autoboot` flag – disabling `autoboot` also implies opting-out of - globals mode support, although they are ultimately orthgonal concerns. + globals mode support, although they are ultimately orthogonal concerns. Most of the global modes features are already deprecated in 1.x. The - existance of this flag is to untangle the globals mode code paths from + existence of this flag is to untangle the globals mode code paths from the autoboot code paths, so that these legacy features can be reviewed for removal separately. @@ -435,7 +435,7 @@ var Application = Namespace.extend(RegistryProxy, { Build the deprecated instance for legacy globals mode support. Called when creating and resetting the application. - This is orthgonal to autoboot: the deprecated instance needs to + This is orthogonal to autoboot: the deprecated instance needs to be created at Application construction (not boot) time to expose App.__container__ and the global Ember.View.views registry. If autoboot sees that this instance exists, it will continue booting @@ -504,10 +504,11 @@ var Application = Namespace.extend(RegistryProxy, { } ``` - Unfortunately, because we need to participate in the "synchronous" boot - process. While the code above would work fine on the initial boot (i.e. - DOM ready), when `App.reset()` is called, we need to boot a new instance - synchronously (see the documentation on `_bootSync()` for details). + Unfortunately, we cannot actually write this because we need to participate + in the "synchronous" boot process. While the code above would work fine on + the initial boot (i.e. DOM ready), when `App.reset()` is called, we need to + boot a new instance synchronously (see the documentation on `_bootSync()` + for details). Because of this restriction, the actual logic of this method is located inside `didBecomeReady()`. @@ -981,8 +982,9 @@ if (isEnabled('ember-application-visit')) { resolves with the instance when the initial routing and rendering is complete, or rejects with any error that occured during the boot process. - When `autoboot` is disabled, calling `visit` would first cause boot the - application. See the documentation on the `boot` method for details. + When `autoboot` is disabled, calling `visit` would first cause the + application to boot. See the documentation on the `boot` method for + details. This method also takes a hash of boot-time configuration options for customizing the instance's behavior. See the documentation on @@ -1011,7 +1013,7 @@ if (isEnabled('ember-application-visit')) { correctly today, largely due to Ember's jQuery dependency. Currently, there are three officially supported scenarios/configurations. - Usages outside of these scenarios are not guarenteed to work, but please + Usages outside of these scenarios are not guaranteed to work, but please feel free to file bug reports documenting your experience and any issues you encountered to help expand support.
true
Other
emberjs
ember.js
008f1dcd1605cfe925f9b754316e0d4d5036a1a2.json
Use ES6 default parameters
packages/ember-application/lib/system/application-instance.js
@@ -372,9 +372,7 @@ if (isEnabled('ember-application-visit')) { @namespace @Ember.ApplicationInstance @public */ - BootOptions = function BootOptions(options) { - options = options || {}; - + BootOptions = function BootOptions(options = {}) { /** Provide a specific instance of jQuery. This is useful in conjunction with the `document` option, as it allows you to use a copy of `jQuery` that is
true
Other
emberjs
ember.js
008f1dcd1605cfe925f9b754316e0d4d5036a1a2.json
Use ES6 default parameters
packages/ember-application/lib/system/application.js
@@ -406,10 +406,8 @@ var Application = Namespace.extend(RegistryProxy, { @method buildInstance @return {Ember.ApplicationInstance} the application instance */ - buildInstance(options) { - options = options || {}; + buildInstance(options = {}) { options.application = this; - return ApplicationInstance.create(options); },
true
Other
emberjs
ember.js
7329fe9fac2644d4ecbde69e76ec0351f551820d.json
Ensure test waits properly for async test helper. Without this, the test will timeout after 1s (regardless of `QUnit.config.testTimeout` setting which is not used unless you are using `QUnit.asyncTest`, `assert.async`, or `QUnit.stop`).
packages/ember-testing/tests/helper_registration_test.js
@@ -53,15 +53,18 @@ QUnit.test('Helper gets registered', function() { ok(helperContainer.boot); }); -QUnit.test('Helper is ran when called', function() { - expect(1); +QUnit.test('Helper is ran when called', function(assert) { + let done = assert.async(); + assert.expect(1); registerHelper(); setupApp(); - App.testHelpers.boot().then(function() { - ok(appBooted); - }); + App.testHelpers.boot() + .then(function() { + assert.ok(appBooted); + }) + .finally(done); }); QUnit.test('Helper can be unregistered', function() { @@ -80,4 +83,3 @@ QUnit.test('Helper can be unregistered', function() { ok(!App.testHelpers.boot, 'once unregistered the helper is not added to App.testHelpers'); ok(!helperContainer.boot, 'once unregistered the helper is not added to the helperContainer'); }); -
false
Other
emberjs
ember.js
bfe3908b2be9ceab76918d68a50f6c521a25e939.json
Update QUnit test timeout to 15 seconds. We have an annoying intermitent test failure that occurs when running tests on older browsers in Sauce Labs. The failure is generally occurring when the VM itself is slower than normal, and will pass after a restart. This increases the timeout to allow more time (from 7 seconds to 15 seconds) in the hopes that this resolves the majority of our random failure scenarios.
tests/index.html
@@ -143,8 +143,8 @@ }); setupQUnit(testHelpers); - // Tests should time out after 5 seconds - QUnit.config.testTimeout = 7500; + // Tests should time out after 15 seconds + QUnit.config.testTimeout = 15000; // Handle testing feature flags QUnit.config.urlConfig.push({ id: 'enableoptionalfeatures', label: "Enable Opt Features"}); // Handle extending prototypes
false
Other
emberjs
ember.js
104e2c6593bf5ba81da0a39bad74f8ab40912e2d.json
Add a FastBoot test to help design the API
packages/ember-application/lib/system/application-instance.js
@@ -11,12 +11,15 @@ import { set } from 'ember-metal/property_set'; import EmberObject from 'ember-runtime/system/object'; import run from 'ember-metal/run_loop'; import { computed } from 'ember-metal/computed'; +import ContainerProxy from 'ember-runtime/mixins/container_proxy'; +import DOMHelper from 'ember-htmlbars/system/dom-helper'; import Registry from 'container/registry'; import RegistryProxy, { buildFakeRegistryWithDeprecations } from 'ember-runtime/mixins/registry_proxy'; -import ContainerProxy from 'ember-runtime/mixins/container_proxy'; +import Renderer from 'ember-metal-views/renderer'; import assign from 'ember-metal/assign'; import environment from 'ember-metal/environment'; + let BootOptions; /** @@ -166,6 +169,14 @@ let ApplicationInstance = EmberObject.extend(RegistryProxy, ContainerProxy, { options = new BootOptions(options); set(this, '_bootOptions', options); + if (options.document) { + this.__registry__.register('renderer:-dom', { + create() { + return new Renderer(new DOMHelper(options.document), options.hasDOM); + } + }); + } + if (options.rootElement) { set(this, 'rootElement', options.rootElement); } else { @@ -320,7 +331,12 @@ if (isEnabled('ember-application-visit')) { let router = get(this, 'router'); let handleResolve = () => { - return this; + // Resolve only after rendering is complete + return new Ember.RSVP.Promise((resolve) => { + // TODO: why is this necessary? Shouldn't 'actions' queue be enough? + // Also, aren't proimses supposed to be async anyway? + run.next(null, resolve, this); + }); }; let handleReject = (error) => { @@ -355,13 +371,25 @@ if (isEnabled('ember-application-visit')) { BootOptions = function BootOptions(options) { options = options || {}; + /** + If present, render into the given `Document` object instead of `window.document`. + + @property document + @type Document + @default null + @private + */ + if (options.document) { + this.document = options.document; + } + /** If present, overrides the `rootElement` property on the instance. This is useful for testing environment, where you might want to append the root view to a fixture area. @property rootElement - @property {String|DOMElement} rootElement + @type String|DOMElement @default null @private */
true
Other
emberjs
ember.js
104e2c6593bf5ba81da0a39bad74f8ab40912e2d.json
Add a FastBoot test to help design the API
packages/ember-application/lib/system/application.js
@@ -992,21 +992,35 @@ if (isEnabled('ember-application-visit')) { @method visit @private */ - visit(url) { + visit(url, options) { return this.boot().then(() => { - let defer = new Ember.RSVP.defer(); - - return this.buildInstance().boot({ - location: 'none', - hasDOM: false, - didCreateRootView(view) { - this.view = view; - defer.resolve(this); - } - }).then((instance) => { + options = options || {}; + + let instance = this.buildInstance(); + + var bootOptions = {}; + + if (options.location !== null) { + bootOptions.location = options.location || 'none'; + } + + if (options.server) { + bootOptions.hasDOM = false; + bootOptions.didCreateRootView = function(view) { + view.renderer.appendTo(view, options.rootElement); + }; + } + + if (options.document) { + bootOptions.document = options.document; + } + + if (options.rootElement) { + bootOptions.rootElement = options.rootElement; + } + + return instance.boot(bootOptions).then(() => { return instance.visit(url); - }).then(() => { - return defer.promise; }); }); }
true
Other
emberjs
ember.js
104e2c6593bf5ba81da0a39bad74f8ab40912e2d.json
Add a FastBoot test to help design the API
packages/ember-application/tests/system/visit_test.js
@@ -6,31 +6,43 @@ import ApplicationInstance from 'ember-application/system/application-instance'; import Route from 'ember-routing/system/route'; import Router from 'ember-routing/system/router'; import View from 'ember-views/views/view'; +import Component from 'ember-views/components/component'; import compile from 'ember-template-compiler/system/compile'; let App = null; let instance = null; +let instances = []; -function createApplication() { +function createApplication(integration) { App = Application.extend().create({ autoboot: false, + rootElement: '#qunit-fixture', LOG_TRANSITIONS: true, LOG_TRANSITIONS_INTERNAL: true, LOG_ACTIVE_GENERATION: true }); App.Router = Router.extend(); - App.instanceInitializer({ - name: 'auto-cleanup', - initialize(_instance) { - if (instance) { - run(instance, 'destroy'); + if (integration) { + App.instanceInitializer({ + name: 'auto-cleanup', + initialize(_instance) { + instances.push(_instance); } + }); + } else { + App.instanceInitializer({ + name: 'auto-cleanup', + initialize(_instance) { + if (instance) { + run(instance, 'destroy'); + } - instance = _instance; - } - }); + instance = _instance; + } + }); + } return App; } @@ -393,8 +405,6 @@ if (isEnabled('ember-application-visit')) { App.visit('/').then(function(instance) { QUnit.start(); assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); - - run(instance.view, 'appendTo', '#qunit-fixture'); assert.equal(Ember.$('#qunit-fixture > .ember-view h1').text(), 'Hello world', 'the application was rendered once the promise resolves'); }, function(error) { QUnit.start(); @@ -427,8 +437,6 @@ if (isEnabled('ember-application-visit')) { App.visit('/').then(function(instance) { QUnit.start(); assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); - - run(instance.view, 'appendTo', '#qunit-fixture'); assert.equal(Ember.$('#qunit-fixture > #my-cool-app h1').text(), 'Hello world', 'the application was rendered once the promise resolves'); assert.strictEqual(View.views['my-cool-app'], undefined, 'view was not registered globally'); @@ -448,4 +456,126 @@ if (isEnabled('ember-application-visit')) { }); }); }); + + QUnit.module('Ember.Application - visit() Integration Tests', { + teardown() { + if (instances) { + run(instances, 'forEach', (i) => i.destroy()); + instances = []; + } + + if (App) { + run(App, 'destroy'); + App = null; + } + } + }); + + QUnit.test('FastBoot-style setup', function(assert) { + QUnit.expect(15); + QUnit.stop(); + + let initCalled = false; + let didInsertElementCalled = false; + + run(function() { + createApplication(true); + + App.Router.map(function() { + this.route('a'); + this.route('b'); + }); + + App.register('template:application', compile('<h1>Hello world</h1>\n{{outlet}}')); + + App.register('template:a', compile('<h2>Welcome to {{x-foo page="A"}}</h2>')); + + App.register('template:b', compile('<h2>{{x-foo page="B"}}</h2>')); + + App.register('template:components/x-foo', compile('Page {{page}}')); + + App.register('component:x-foo', Component.extend({ + tagName: 'span', + init() { + this._super(); + initCalled = true; + }, + didInsertElement() { + didInsertElementCalled = true; + } + })); + }); + + assert.equal(Ember.$('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element'); + + function makeFakeDom() { + // TODO: use simple-dom + return document.implementation.createHTMLDocument(); + } + + let a = run(function() { + let dom = makeFakeDom(); + + return App.visit('/a', { document: dom, rootElement: dom.body, server: true }).then(instance => { + QUnit.start(); + assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); + assert.equal(instance.getURL(), '/a'); + + let serialized = dom.body.innerHTML; + let $parsed = Ember.$(serialized); + + assert.equal($parsed.find('h1').text(), 'Hello world'); + assert.equal($parsed.find('h2').text(), 'Welcome to Page A'); + + assert.ok(initCalled, 'Component#init should be called'); + assert.ok(!didInsertElementCalled, 'Component#didInsertElement should not be called'); + + assert.equal(Ember.$('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element'); + QUnit.stop(); + }); + }); + + let b = run(function() { + let dom = makeFakeDom(); + + return App.visit('/b', { document: dom, rootElement: dom.body, server: true }).then(instance => { + QUnit.start(); + assert.ok(instance instanceof ApplicationInstance, 'promise is resolved with an ApplicationInstance'); + assert.equal(instance.getURL(), '/b'); + + let serialized = dom.body.innerHTML; + let $parsed = Ember.$(serialized); + + assert.equal($parsed.find('h1').text(), 'Hello world'); + assert.equal($parsed.find('h2').text(), 'Page B'); + + assert.ok(initCalled, 'Component#init should be called'); + assert.ok(!didInsertElementCalled, 'Component#didInsertElement should not be called'); + + assert.equal(Ember.$('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element'); + QUnit.stop(); + }); + }); + + Ember.RSVP.all([a, b]).finally(() => QUnit.start()); + }); + + QUnit.test('Ember Islands-style setup', function(assert) { + + }); + + QUnit.skip('Resource-discovery setup', function(assert) { + + + }); + + QUnit.skip('Test setup', function(assert) { + + + }); + + QUnit.skip('iframe setup', function(assert) { + + + }); }
true
Other
emberjs
ember.js
e8e3e1d341402c5ceb587bcf8a291ca1089464b2.json
Finalize namespace before booting instances
packages/ember-application/lib/system/application.js
@@ -721,9 +721,16 @@ var Application = Namespace.extend(RegistryProxy, { */ didBecomeReady() { try { - let instance; + // TODO: Is this needed for globalsMode = false? + if (!Ember.testing) { + // Eagerly name all classes that are already loaded + Ember.Namespace.processAll(); + Ember.BOOTED = true; + } if (this.autoboot) { + let instance; + if (this.globalsMode) { // If we already have the __deprecatedInstance__ lying around, boot it to // avoid unnecessary work @@ -740,16 +747,7 @@ var Application = Namespace.extend(RegistryProxy, { // TODO: App.ready() is not called when autoboot is disabled, is this correct? this.ready(); - } - // TODO: Is this needed for globalsMode = false? - if (!Ember.testing) { - // Eagerly name all classes that are already loaded - Ember.Namespace.processAll(); - Ember.BOOTED = true; - } - - if (this.autoboot) { instance.startRouting(); } } catch(e) {
false
Other
emberjs
ember.js
5b8651097efc014a7da0a0d3e5eb1a3edf34c0b4.json
Fix a string (remove superfluous space)
packages/ember-routing/lib/system/router.js
@@ -268,7 +268,7 @@ var EmberRouter = EmberObject.extend(Evented, { run.once(this, this.trigger, 'willTransition', transition); if (get(this, 'namespace').LOG_TRANSITIONS) { - Ember.Logger.log(`Preparing to transition from '${EmberRouter._routePath(oldInfos)}' to ' ${EmberRouter._routePath(newInfos)}'`); + Ember.Logger.log(`Preparing to transition from '${EmberRouter._routePath(oldInfos)}' to '${EmberRouter._routePath(newInfos)}'`); } },
false
Other
emberjs
ember.js
b60e201209cb0e60939457ad0062376dfaacaa32.json
Remove unsupported global check for class bindings.
packages/ember-views/lib/system/build-component-template.js
@@ -1,7 +1,6 @@ import { assert, deprecate } from 'ember-metal/debug'; import { get } from 'ember-metal/property_get'; import assign from 'ember-metal/assign'; -import { isGlobal } from 'ember-metal/path_cache'; import { internal, render } from 'htmlbars-runtime'; import getValue from 'ember-htmlbars/hooks/get-value'; import { isStream } from 'ember-metal/streams/utils'; @@ -280,8 +279,7 @@ function normalizeClasses(classes, output, streamBasePath) { continue; } - // 2.0TODO: Remove deprecated global path - var prop = isGlobal(propName) ? propName : `${streamBasePath}${propName}`; + var prop = `${streamBasePath}${propName}`; output.push(['subexpr', '-normalize-class', [ // params
false
Other
emberjs
ember.js
da7f6d5b2f5767e682b289997be3c2f4005ea3f3.json
update API docs for `computed` This example was showing the old-style computed property arguments, which were deprecated before 2.0.
packages/ember-metal/lib/computed.js
@@ -526,7 +526,7 @@ ComputedPropertyPrototype.teardown = function(obj, keyName) { firstName: 'Betty', lastName: 'Jones', - fullName: Ember.computed('firstName', 'lastName', function(key, value) { + fullName: Ember.computed('firstName', 'lastName', function() { return this.get('firstName') + ' ' + this.get('lastName'); }) });
false
Other
emberjs
ember.js
cdc496a0fcc9a7cafc01eca7943b59ab59a42081.json
Add names to anon functions in node managers. This makes debugging and profiling a little bit easier (removing some "anonymous functions" and replacing with useful names).
packages/ember-htmlbars/lib/node-managers/component-node-manager.js
@@ -33,7 +33,7 @@ function ComponentNodeManager(component, isAngleBracket, scope, renderNode, attr export default ComponentNodeManager; -ComponentNodeManager.create = function(renderNode, env, options) { +ComponentNodeManager.create = function ComponentNodeManager_create(renderNode, env, options) { let { tagName, params, attrs, @@ -163,10 +163,10 @@ function configureCreateOptions(attrs, createOptions) { if (attrs.viewName) { createOptions.viewName = getValue(attrs.viewName); } } -ComponentNodeManager.prototype.render = function(_env, visitor) { +ComponentNodeManager.prototype.render = function ComponentNodeManager_render(_env, visitor) { var { component } = this; - return instrument(component, function() { + return instrument(component, function ComponentNodeManager_render_instrument() { let env = _env.childWithView(component); env.renderer.componentWillRender(component); @@ -212,10 +212,10 @@ function nextElementSibling(node) { } } -ComponentNodeManager.prototype.rerender = function(_env, attrs, visitor) { +ComponentNodeManager.prototype.rerender = function ComponentNodeManager_rerender(_env, attrs, visitor) { var component = this.component; - return instrument(component, function() { + return instrument(component, function ComponentNodeManager_rerender_instrument() { let env = _env.childWithView(component); var snapshot = takeSnapshot(attrs); @@ -245,7 +245,7 @@ ComponentNodeManager.prototype.rerender = function(_env, attrs, visitor) { }, this); }; -ComponentNodeManager.prototype.destroy = function() { +ComponentNodeManager.prototype.destroy = function ComponentNodeManager_destroy() { let component = this.component; // Clear component's render node. Normally this gets cleared
true
Other
emberjs
ember.js
cdc496a0fcc9a7cafc01eca7943b59ab59a42081.json
Add names to anon functions in node managers. This makes debugging and profiling a little bit easier (removing some "anonymous functions" and replacing with useful names).
packages/ember-htmlbars/lib/node-managers/view-node-manager.js
@@ -26,7 +26,7 @@ function ViewNodeManager(component, scope, renderNode, block, expectElement) { export default ViewNodeManager; -ViewNodeManager.create = function(renderNode, env, attrs, found, parentView, path, contentScope, contentTemplate) { +ViewNodeManager.create = function ViewNodeManager_create(renderNode, env, attrs, found, parentView, path, contentScope, contentTemplate) { assert('HTMLBars error: Could not find component named "' + path + '" (no component or template with that name was found)', function() { if (path) { return found.component || found.layout; @@ -80,10 +80,10 @@ ViewNodeManager.create = function(renderNode, env, attrs, found, parentView, pat return new ViewNodeManager(component, contentScope, renderNode, results.block, results.createdElement); }; -ViewNodeManager.prototype.render = function(env, attrs, visitor) { +ViewNodeManager.prototype.render = function ViewNodeManager_render(env, attrs, visitor) { var component = this.component; - return instrument(component, function() { + return instrument(component, function ViewNodeManager_render_instrument() { var newEnv = env; if (component) { newEnv = env.childWithView(component); @@ -112,10 +112,10 @@ ViewNodeManager.prototype.render = function(env, attrs, visitor) { }, this); }; -ViewNodeManager.prototype.rerender = function(env, attrs, visitor) { +ViewNodeManager.prototype.rerender = function ViewNodeManager_rerender(env, attrs, visitor) { var component = this.component; - return instrument(component, function() { + return instrument(component, function ViewNodeManager_rerender_instrument() { var newEnv = env; if (component) { newEnv = env.childWithView(component); @@ -146,7 +146,7 @@ ViewNodeManager.prototype.rerender = function(env, attrs, visitor) { }, this); }; -ViewNodeManager.prototype.destroy = function() { +ViewNodeManager.prototype.destroy = function ViewNodeManager_destroy() { if (this.component) { this.component.destroy(); this.component = null;
true
Other
emberjs
ember.js
d15e699c6da8db3fdbd78a7c1fcf7c1cfbdc029a.json
Update HTMLBars version. https://github.com/tildeio/htmlbars/compare/v0.14.4...v0.14.5
package.json
@@ -33,7 +33,7 @@ "finalhandler": "^0.4.0", "github": "^0.2.3", "glob": "~4.3.2", - "htmlbars": "0.14.4", + "htmlbars": "0.14.5", "qunit-extras": "^1.3.0", "qunitjs": "^1.16.0", "route-recognizer": "0.1.5",
false
Other
emberjs
ember.js
87190229e133deab859fbc935e8241f8c667936d.json
Implement Template scopes as classes Similar to `meta`, this commit restructures the scope away from pervasive use of `Object.create` into a custom JavaScript object. This has two benefits: 1. We only need a single parent pointer, rather than having every map inherit from its parent map. 2. v8 penalizes us for using `Object.create` by often assuming we are creating something more class-like and eventually blowing up methods that use scopes. Eventually, this scope refactoring will probably replace some of the hooks in HTMLBars.
packages/ember-htmlbars/lib/env.js
@@ -7,14 +7,16 @@ import merge from 'ember-metal/merge'; import subexpr from 'ember-htmlbars/hooks/subexpr'; import concat from 'ember-htmlbars/hooks/concat'; import linkRenderNode from 'ember-htmlbars/hooks/link-render-node'; -import createFreshScope from 'ember-htmlbars/hooks/create-fresh-scope'; +import createFreshScope, { createChildScope } from 'ember-htmlbars/hooks/create-fresh-scope'; import bindShadowScope from 'ember-htmlbars/hooks/bind-shadow-scope'; import bindSelf from 'ember-htmlbars/hooks/bind-self'; import bindScope from 'ember-htmlbars/hooks/bind-scope'; import bindLocal from 'ember-htmlbars/hooks/bind-local'; +import bindBlock from 'ember-htmlbars/hooks/bind-block'; import updateSelf from 'ember-htmlbars/hooks/update-self'; import getRoot from 'ember-htmlbars/hooks/get-root'; import getChild from 'ember-htmlbars/hooks/get-child'; +import getBlock from 'ember-htmlbars/hooks/get-block'; import getValue from 'ember-htmlbars/hooks/get-value'; import getCellOrValue from 'ember-htmlbars/hooks/get-cell-or-value'; import cleanupRenderNode from 'ember-htmlbars/hooks/cleanup-render-node'; @@ -40,11 +42,14 @@ emberHooks.keywords = keywords; merge(emberHooks, { linkRenderNode, createFreshScope, + createChildScope, bindShadowScope, bindSelf, bindScope, bindLocal, + bindBlock, updateSelf, + getBlock, getRoot, getChild, getValue, @@ -74,6 +79,7 @@ import partial from 'ember-htmlbars/keywords/partial'; import input from 'ember-htmlbars/keywords/input'; import textarea from 'ember-htmlbars/keywords/textarea'; import collection from 'ember-htmlbars/keywords/collection'; +import yieldKeyword from 'ember-htmlbars/keywords/yield'; import legacyYield from 'ember-htmlbars/keywords/legacy-yield'; import mut, { privateMut } from 'ember-htmlbars/keywords/mut'; import each from 'ember-htmlbars/keywords/each'; @@ -88,6 +94,7 @@ registerKeyword('component', componentKeyword); registerKeyword('partial', partial); registerKeyword('input', input); registerKeyword('textarea', textarea); +registerKeyword('yield', yieldKeyword); registerKeyword('legacy-yield', legacyYield); registerKeyword('mut', mut); registerKeyword('@mut', privateMut);
true
Other
emberjs
ember.js
87190229e133deab859fbc935e8241f8c667936d.json
Implement Template scopes as classes Similar to `meta`, this commit restructures the scope away from pervasive use of `Object.create` into a custom JavaScript object. This has two benefits: 1. We only need a single parent pointer, rather than having every map inherit from its parent map. 2. v8 penalizes us for using `Object.create` by often assuming we are creating something more class-like and eventually blowing up methods that use scopes. Eventually, this scope refactoring will probably replace some of the hooks in HTMLBars.
packages/ember-htmlbars/lib/hooks/bind-block.js
@@ -0,0 +1,3 @@ +export default function bindBlock(env, scope, block, name='default') { + scope.bindBlock(name, block); +}
true
Other
emberjs
ember.js
87190229e133deab859fbc935e8241f8c667936d.json
Implement Template scopes as classes Similar to `meta`, this commit restructures the scope away from pervasive use of `Object.create` into a custom JavaScript object. This has two benefits: 1. We only need a single parent pointer, rather than having every map inherit from its parent map. 2. v8 penalizes us for using `Object.create` by often assuming we are creating something more class-like and eventually blowing up methods that use scopes. Eventually, this scope refactoring will probably replace some of the hooks in HTMLBars.
packages/ember-htmlbars/lib/hooks/bind-local.js
@@ -7,15 +7,14 @@ import Stream from 'ember-metal/streams/stream'; import ProxyStream from 'ember-metal/streams/proxy-stream'; export default function bindLocal(env, scope, key, value) { - var isExisting = scope.locals.hasOwnProperty(key); - if (isExisting) { - var existing = scope.locals[key]; - + // TODO: What is the cause of these cases? + if (scope.hasOwnLocal(key)) { + let existing = scope.getLocal(key); if (existing !== value) { existing.setSource(value); } } else { - var newValue = Stream.wrap(value, ProxyStream, key); - scope.locals[key] = newValue; + let newValue = Stream.wrap(value, ProxyStream, key); + scope.bindLocal(key, newValue); } }
true
Other
emberjs
ember.js
87190229e133deab859fbc935e8241f8c667936d.json
Implement Template scopes as classes Similar to `meta`, this commit restructures the scope away from pervasive use of `Object.create` into a custom JavaScript object. This has two benefits: 1. We only need a single parent pointer, rather than having every map inherit from its parent map. 2. v8 penalizes us for using `Object.create` by often assuming we are creating something more class-like and eventually blowing up methods that use scopes. Eventually, this scope refactoring will probably replace some of the hooks in HTMLBars.
packages/ember-htmlbars/lib/hooks/bind-self.js
@@ -3,7 +3,7 @@ @submodule ember-htmlbars */ -import newStream from 'ember-htmlbars/utils/new-stream'; +import ProxyStream from 'ember-metal/streams/proxy-stream'; export default function bindSelf(env, scope, _self) { let self = _self; @@ -12,25 +12,32 @@ export default function bindSelf(env, scope, _self) { let { controller } = self; self = self.self; - newStream(scope.locals, 'controller', controller || self); + scope.bindLocal('controller', newStream(controller || self)); } if (self && self.isView) { - newStream(scope.locals, 'view', self, null); - newStream(scope.locals, 'controller', scope.locals.view.getKey('controller')); + scope.bindLocal('view', newStream(self, 'view')); + scope.bindLocal('controller', newStream(self, '').getKey('controller')); + + let selfStream = newStream(self, ''); if (self.isGlimmerComponent) { - newStream(scope, 'self', self, null, true); + scope.bindSelf(selfStream); } else { - newStream(scope, 'self', scope.locals.view.getKey('context'), null, true); + scope.bindSelf(newStream(selfStream.getKey('context'), '')); } return; } - newStream(scope, 'self', self, null, true); + let selfStream = newStream(self, ''); + scope.bindSelf(selfStream); - if (!scope.locals.controller) { - scope.locals.controller = scope.self; + if (!scope.hasLocal('controller')) { + scope.bindLocal('controller', selfStream); } } + +function newStream(newValue, key) { + return new ProxyStream(newValue, key); +}
true
Other
emberjs
ember.js
87190229e133deab859fbc935e8241f8c667936d.json
Implement Template scopes as classes Similar to `meta`, this commit restructures the scope away from pervasive use of `Object.create` into a custom JavaScript object. This has two benefits: 1. We only need a single parent pointer, rather than having every map inherit from its parent map. 2. v8 penalizes us for using `Object.create` by often assuming we are creating something more class-like and eventually blowing up methods that use scopes. Eventually, this scope refactoring will probably replace some of the hooks in HTMLBars.
packages/ember-htmlbars/lib/hooks/bind-shadow-scope.js
@@ -3,7 +3,7 @@ @submodule ember-htmlbars */ -import newStream from 'ember-htmlbars/utils/new-stream'; +import ProxyStream from 'ember-metal/streams/proxy-stream'; export default function bindShadowScope(env, parentScope, shadowScope, options) { if (!options) { return; } @@ -12,31 +12,35 @@ export default function bindShadowScope(env, parentScope, shadowScope, options) if (parentScope && parentScope.overrideController) { didOverrideController = true; - shadowScope.locals.controller = parentScope.locals.controller; + shadowScope.bindLocal('controller', parentScope.getLocal('controller')); } var view = options.view; if (view && !view.isComponent) { - newStream(shadowScope.locals, 'view', view, null); + shadowScope.bindLocal('view', newStream(view, 'view')); if (!didOverrideController) { - newStream(shadowScope.locals, 'controller', shadowScope.locals.view.getKey('controller')); + shadowScope.bindLocal('controller', newStream(shadowScope.getLocal('view').getKey('controller'))); } if (view.isView) { - newStream(shadowScope, 'self', shadowScope.locals.view.getKey('context'), null, true); + shadowScope.bindSelf(newStream(shadowScope.getLocal('view').getKey('context'), '')); } } - shadowScope.view = view; + shadowScope.bindView(view); if (view && options.attrs) { - shadowScope.component = view; + shadowScope.bindComponent(view); } if ('attrs' in options) { - shadowScope.attrs = options.attrs; + shadowScope.bindAttrs(options.attrs); } return shadowScope; } + +function newStream(newValue, key) { + return new ProxyStream(newValue, key); +}
true
Other
emberjs
ember.js
87190229e133deab859fbc935e8241f8c667936d.json
Implement Template scopes as classes Similar to `meta`, this commit restructures the scope away from pervasive use of `Object.create` into a custom JavaScript object. This has two benefits: 1. We only need a single parent pointer, rather than having every map inherit from its parent map. 2. v8 penalizes us for using `Object.create` by often assuming we are creating something more class-like and eventually blowing up methods that use scopes. Eventually, this scope refactoring will probably replace some of the hooks in HTMLBars.
packages/ember-htmlbars/lib/hooks/component.js
@@ -77,7 +77,7 @@ export default function componentHook(renderNode, env, scope, _tagName, params, tagName, isAngleBracket: true, isComponentElement: true, - outerAttrs: scope.attrs, + outerAttrs: scope.getAttrs(), parentScope: scope };
true
Other
emberjs
ember.js
87190229e133deab859fbc935e8241f8c667936d.json
Implement Template scopes as classes Similar to `meta`, this commit restructures the scope away from pervasive use of `Object.create` into a custom JavaScript object. This has two benefits: 1. We only need a single parent pointer, rather than having every map inherit from its parent map. 2. v8 penalizes us for using `Object.create` by often assuming we are creating something more class-like and eventually blowing up methods that use scopes. Eventually, this scope refactoring will probably replace some of the hooks in HTMLBars.
packages/ember-htmlbars/lib/hooks/create-fresh-scope.js
@@ -1,3 +1,5 @@ +import ProxyStream from 'ember-metal/streams/proxy-stream'; + /* Ember's implementation of HTMLBars creates an enriched scope. @@ -46,13 +48,114 @@ the current view's `controller`. */ +function Scope(parent) { + this._self = null; + this._blocks = {}; + this._component = null; + this._view = null; + this._attrs = null; + this._locals = {}; + this._localPresent = {}; + this.overrideController = false; + this.parent = parent; +} + +let proto = Scope.prototype; + +proto.getSelf = function() { + return this._self || this.parent.getSelf(); +}; + +proto.bindSelf = function(self) { + this._self = self; +}; + +proto.updateSelf = function(self, key) { + let existing = this._self; + + if (existing) { + existing.setSource(self); + } else { + this._self = new ProxyStream(self, key); + } +}; + +proto.getBlock = function(name) { + return this._blocks[name] || this.parent.getBlock(name); +}; + +proto.hasBlock = function(name) { + return !!(this._blocks[name] || this.parent.hasBlock(name)); +}; + +proto.bindBlock = function(name, block) { + this._blocks[name] = block; +}; + +proto.getComponent = function() { + return this._component || this.parent.getComponent(); +}; + +proto.bindComponent = function(component) { + this._component = component; +}; + +proto.getView = function() { + return this._view || this.parent.getView(); +}; + +proto.bindView = function(view) { + this._view = view; +}; + +proto.getAttrs = function() { + return this._attrs || this.parent.getAttrs(); +}; + +proto.bindAttrs = function(attrs) { + this._attrs = attrs; +}; + +proto.hasLocal = function(name) { + return this._localPresent[name] || this.parent.hasLocal(name); +}; + +proto.hasOwnLocal = function(name) { + return this._localPresent[name]; +}; + +proto.getLocal = function(name) { + return this._localPresent[name] ? this._locals[name] : this.parent.getLocal(name); +}; + +proto.bindLocal = function(name, value) { + this._localPresent[name] = true; + this._locals[name] = value; +}; + +const EMPTY = { + getSelf() { return null; }, + bindSelf(self) { return null; }, + updateSelf(self, key) { return null; }, + getBlock(name) { return null; }, + bindBlock(name, block) { return null; }, + hasBlock(name) { return false; }, + getComponent() { return null; }, + bindComponent() { return null; }, + getView() { return null; }, + bindView(view) { return null; }, + getAttrs() { return null; }, + bindAttrs(attrs) { return null; }, + hasLocal(name) { return false; }, + hasOwnLocal(name) { return false; }, + getLocal(name) { return null; }, + bindLocal(name, value) { return null; } +}; + export default function createFreshScope() { - return { - self: null, - blocks: {}, - component: null, - attrs: null, - locals: {}, - localPresent: {} - }; + return new Scope(EMPTY); +} + +export function createChildScope(parent) { + return new Scope(parent); }
true
Other
emberjs
ember.js
87190229e133deab859fbc935e8241f8c667936d.json
Implement Template scopes as classes Similar to `meta`, this commit restructures the scope away from pervasive use of `Object.create` into a custom JavaScript object. This has two benefits: 1. We only need a single parent pointer, rather than having every map inherit from its parent map. 2. v8 penalizes us for using `Object.create` by often assuming we are creating something more class-like and eventually blowing up methods that use scopes. Eventually, this scope refactoring will probably replace some of the hooks in HTMLBars.
packages/ember-htmlbars/lib/hooks/element.js
@@ -13,7 +13,7 @@ export default function emberElement(morph, env, scope, path, params, hash, visi } var result; - var helper = findHelper(path, scope.self, env); + var helper = findHelper(path, scope.getSelf(), env); if (helper) { var helperStream = buildHelperStream(helper, params, hash, { element: morph.element }, env, scope, path); result = helperStream.value();
true
Other
emberjs
ember.js
87190229e133deab859fbc935e8241f8c667936d.json
Implement Template scopes as classes Similar to `meta`, this commit restructures the scope away from pervasive use of `Object.create` into a custom JavaScript object. This has two benefits: 1. We only need a single parent pointer, rather than having every map inherit from its parent map. 2. v8 penalizes us for using `Object.create` by often assuming we are creating something more class-like and eventually blowing up methods that use scopes. Eventually, this scope refactoring will probably replace some of the hooks in HTMLBars.
packages/ember-htmlbars/lib/hooks/get-block.js
@@ -0,0 +1,3 @@ +export default function getBlock(scope, key) { + return scope.getBlock(key); +}
true
Other
emberjs
ember.js
87190229e133deab859fbc935e8241f8c667936d.json
Implement Template scopes as classes Similar to `meta`, this commit restructures the scope away from pervasive use of `Object.create` into a custom JavaScript object. This has two benefits: 1. We only need a single parent pointer, rather than having every map inherit from its parent map. 2. v8 penalizes us for using `Object.create` by often assuming we are creating something more class-like and eventually blowing up methods that use scopes. Eventually, this scope refactoring will probably replace some of the hooks in HTMLBars.
packages/ember-htmlbars/lib/hooks/get-root.js
@@ -5,30 +5,35 @@ export default function getRoot(scope, key) { if (key === 'this') { - return [scope.self]; + return [scope.getSelf()]; } else if (key === 'hasBlock') { - return [!!scope.blocks.default]; + return [!!scope.hasBlock('default')]; } else if (key === 'hasBlockParams') { - return [!!(scope.blocks.default && scope.blocks.default.arity)]; - } else if (key in scope.locals) { - return [scope.locals[key]]; + let block = scope.getBlock('default'); + return [!!block && block.arity]; + } else if (scope.hasLocal(key)) { + return [scope.getLocal(key)]; } else { return [getKey(scope, key)]; } } function getKey(scope, key) { - if (key === 'attrs' && scope.attrs) { - return scope.attrs; + if (key === 'attrs') { + let attrs = scope.getAttrs(); + if (attrs) { return attrs; } } - var self = scope.self || scope.locals.view; + var self = scope.getSelf() || scope.getLocal('view'); if (self) { return self.getKey(key); - } else if (scope.attrs && key in scope.attrs) { + } + + let attrs = scope.getAttrs(); + if (key in attrs) { // TODO: attrs // deprecate("You accessed the `" + key + "` attribute directly. Please use `attrs." + key + "` instead."); - return scope.attrs[key]; + return attrs[key]; } }
true
Other
emberjs
ember.js
87190229e133deab859fbc935e8241f8c667936d.json
Implement Template scopes as classes Similar to `meta`, this commit restructures the scope away from pervasive use of `Object.create` into a custom JavaScript object. This has two benefits: 1. We only need a single parent pointer, rather than having every map inherit from its parent map. 2. v8 penalizes us for using `Object.create` by often assuming we are creating something more class-like and eventually blowing up methods that use scopes. Eventually, this scope refactoring will probably replace some of the hooks in HTMLBars.
packages/ember-htmlbars/lib/hooks/lookup-helper.js
@@ -1,5 +1,5 @@ import lookupHelper from 'ember-htmlbars/system/lookup-helper'; export default function lookupHelperHook(env, scope, helperName) { - return lookupHelper(helperName, scope.self, env); + return lookupHelper(helperName, scope.getSelf(), env); }
true
Other
emberjs
ember.js
87190229e133deab859fbc935e8241f8c667936d.json
Implement Template scopes as classes Similar to `meta`, this commit restructures the scope away from pervasive use of `Object.create` into a custom JavaScript object. This has two benefits: 1. We only need a single parent pointer, rather than having every map inherit from its parent map. 2. v8 penalizes us for using `Object.create` by often assuming we are creating something more class-like and eventually blowing up methods that use scopes. Eventually, this scope refactoring will probably replace some of the hooks in HTMLBars.
packages/ember-htmlbars/lib/hooks/subexpr.js
@@ -19,7 +19,7 @@ export default function subexpr(env, scope, helperName, params, hash) { } var label = labelForSubexpr(params, hash, helperName); - var helper = lookupHelper(helperName, scope.self, env); + var helper = lookupHelper(helperName, scope.getSelf(), env); var helperStream = buildHelperStream(helper, params, hash, null, env, scope, label);
true
Other
emberjs
ember.js
87190229e133deab859fbc935e8241f8c667936d.json
Implement Template scopes as classes Similar to `meta`, this commit restructures the scope away from pervasive use of `Object.create` into a custom JavaScript object. This has two benefits: 1. We only need a single parent pointer, rather than having every map inherit from its parent map. 2. v8 penalizes us for using `Object.create` by often assuming we are creating something more class-like and eventually blowing up methods that use scopes. Eventually, this scope refactoring will probably replace some of the hooks in HTMLBars.
packages/ember-htmlbars/lib/hooks/update-self.js
@@ -5,7 +5,6 @@ import { assert } from 'ember-metal/debug'; import { get } from 'ember-metal/property_get'; -import updateScope from 'ember-htmlbars/utils/update-scope'; export default function updateSelf(env, scope, _self) { let self = _self; @@ -14,16 +13,16 @@ export default function updateSelf(env, scope, _self) { let { controller } = self; self = self.self; - updateScope(scope.locals, 'controller', controller || self); + scope.updateLocal('controller', controller || self); } assert('BUG: scope.attrs and self.isView should not both be true', !(scope.attrs && self.isView)); if (self && self.isView) { - updateScope(scope.locals, 'view', self, null); - updateScope(scope, 'self', get(self, 'context'), null, true); + scope.updateLocal('view', self); + scope.updateSelf(get(self, 'context'), ''); return; } - updateScope(scope, 'self', self, null); + scope.updateSelf(self); }
true
Other
emberjs
ember.js
87190229e133deab859fbc935e8241f8c667936d.json
Implement Template scopes as classes Similar to `meta`, this commit restructures the scope away from pervasive use of `Object.create` into a custom JavaScript object. This has two benefits: 1. We only need a single parent pointer, rather than having every map inherit from its parent map. 2. v8 penalizes us for using `Object.create` by often assuming we are creating something more class-like and eventually blowing up methods that use scopes. Eventually, this scope refactoring will probably replace some of the hooks in HTMLBars.
packages/ember-htmlbars/lib/keywords/debugger.js
@@ -52,8 +52,8 @@ import { info } from 'ember-metal/debug'; export default function debuggerKeyword(morph, env, scope) { /* jshint unused: false, debug: true */ - var view = env.hooks.getValue(scope.locals.view); - var context = env.hooks.getValue(scope.self); + var view = env.hooks.getValue(scope.getLocal('view')); + var context = env.hooks.getValue(scope.getSelf()); function get(path) { return env.hooks.getValue(env.hooks.get(env, scope, path));
true
Other
emberjs
ember.js
87190229e133deab859fbc935e8241f8c667936d.json
Implement Template scopes as classes Similar to `meta`, this commit restructures the scope away from pervasive use of `Object.create` into a custom JavaScript object. This has two benefits: 1. We only need a single parent pointer, rather than having every map inherit from its parent map. 2. v8 penalizes us for using `Object.create` by often assuming we are creating something more class-like and eventually blowing up methods that use scopes. Eventually, this scope refactoring will probably replace some of the hooks in HTMLBars.
packages/ember-htmlbars/lib/keywords/legacy-yield.js
@@ -2,21 +2,22 @@ import ProxyStream from 'ember-metal/streams/proxy-stream'; export default function legacyYield(morph, env, _scope, params, hash, template, inverse, visitor) { let scope = _scope; + let block = scope.getBlock('default'); - if (scope.blocks.default.arity === 0) { + if (block.arity === 0) { // Typically, the `controller` local is persists through lexical scope. // However, in this case, the `{{legacy-yield}}` in the legacy each view // needs to override the controller local for the template it is yielding. // This megahaxx allows us to override the controller, and most importantly, // prevents the downstream scope from attempting to bind the `controller` local. if (hash.controller) { scope = env.hooks.createChildScope(scope); - scope.locals.controller = new ProxyStream(hash.controller, 'controller'); + scope.bindLocal('controller', new ProxyStream(hash.controller, 'controller')); scope.overrideController = true; } - scope.blocks.default.invoke(env, [], params[0], morph, scope, visitor); + block.invoke(env, [], params[0], morph, scope, visitor); } else { - scope.blocks.default.invoke(env, params, undefined, morph, scope, visitor); + block.invoke(env, params, undefined, morph, scope, visitor); } return true;
true
Other
emberjs
ember.js
87190229e133deab859fbc935e8241f8c667936d.json
Implement Template scopes as classes Similar to `meta`, this commit restructures the scope away from pervasive use of `Object.create` into a custom JavaScript object. This has two benefits: 1. We only need a single parent pointer, rather than having every map inherit from its parent map. 2. v8 penalizes us for using `Object.create` by often assuming we are creating something more class-like and eventually blowing up methods that use scopes. Eventually, this scope refactoring will probably replace some of the hooks in HTMLBars.
packages/ember-htmlbars/lib/keywords/view.js
@@ -188,15 +188,15 @@ import ViewNodeManager from 'ember-htmlbars/node-managers/view-node-manager'; export default { setupState(state, env, scope, params, hash) { var read = env.hooks.getValue; - var targetObject = read(scope.self); + var targetObject = read(scope.getSelf()); var viewClassOrInstance = state.viewClassOrInstance; if (!viewClassOrInstance) { viewClassOrInstance = getView(read(params[0]), env.container); } // if parentView exists, use its controller (the default // behavior), otherwise use `scope.self` as the controller - var controller = scope.locals.view ? null : read(scope.self); + var controller = scope.hasLocal('view') ? null : read(scope.getSelf()); return { manager: state.manager,
true
Other
emberjs
ember.js
87190229e133deab859fbc935e8241f8c667936d.json
Implement Template scopes as classes Similar to `meta`, this commit restructures the scope away from pervasive use of `Object.create` into a custom JavaScript object. This has two benefits: 1. We only need a single parent pointer, rather than having every map inherit from its parent map. 2. v8 penalizes us for using `Object.create` by often assuming we are creating something more class-like and eventually blowing up methods that use scopes. Eventually, this scope refactoring will probably replace some of the hooks in HTMLBars.
packages/ember-htmlbars/lib/keywords/yield.js
@@ -0,0 +1,10 @@ +export default function yieldKeyword(morph, env, scope, params, hash, template, inverse, visitor) { + let to = env.hooks.getValue(hash.to) || 'default'; + let block = scope.getBlock(to); + + if (block) { + block.invoke(env, params, hash.self, morph, scope, visitor); + } + + return true; +}
true
Other
emberjs
ember.js
87190229e133deab859fbc935e8241f8c667936d.json
Implement Template scopes as classes Similar to `meta`, this commit restructures the scope away from pervasive use of `Object.create` into a custom JavaScript object. This has two benefits: 1. We only need a single parent pointer, rather than having every map inherit from its parent map. 2. v8 penalizes us for using `Object.create` by often assuming we are creating something more class-like and eventually blowing up methods that use scopes. Eventually, this scope refactoring will probably replace some of the hooks in HTMLBars.
packages/ember-htmlbars/lib/node-managers/component-node-manager.js
@@ -62,8 +62,8 @@ ComponentNodeManager.create = function(renderNode, env, options) { // If there is a controller on the scope, pluck it off and save it on the // component. This allows the component to target actions sent via // `sendAction` correctly. - if (parentScope.locals.controller) { - createOptions._controller = getValue(parentScope.locals.controller); + if (parentScope.hasLocal('controller')) { + createOptions._controller = getValue(parentScope.getLocal('controller')); } extractPositionalParams(renderNode, component, params, attrs);
true
Other
emberjs
ember.js
87190229e133deab859fbc935e8241f8c667936d.json
Implement Template scopes as classes Similar to `meta`, this commit restructures the scope away from pervasive use of `Object.create` into a custom JavaScript object. This has two benefits: 1. We only need a single parent pointer, rather than having every map inherit from its parent map. 2. v8 penalizes us for using `Object.create` by often assuming we are creating something more class-like and eventually blowing up methods that use scopes. Eventually, this scope refactoring will probably replace some of the hooks in HTMLBars.
packages/ember-htmlbars/lib/node-managers/view-node-manager.js
@@ -46,8 +46,11 @@ ViewNodeManager.create = function(renderNode, env, attrs, found, parentView, pat if (attrs && attrs._defaultTagName) { options._defaultTagName = getValue(attrs._defaultTagName); } if (attrs && attrs.viewName) { options.viewName = getValue(attrs.viewName); } - if (found.component.create && contentScope && contentScope.self) { - options._context = getValue(contentScope.self); + if (found.component.create && contentScope) { + let _self = contentScope.getSelf(); + if (_self) { + options._context = getValue(contentScope.getSelf()); + } } if (found.self) {
true
Other
emberjs
ember.js
87190229e133deab859fbc935e8241f8c667936d.json
Implement Template scopes as classes Similar to `meta`, this commit restructures the scope away from pervasive use of `Object.create` into a custom JavaScript object. This has two benefits: 1. We only need a single parent pointer, rather than having every map inherit from its parent map. 2. v8 penalizes us for using `Object.create` by often assuming we are creating something more class-like and eventually blowing up methods that use scopes. Eventually, this scope refactoring will probably replace some of the hooks in HTMLBars.
packages/ember-htmlbars/lib/utils/subscribe.js
@@ -2,7 +2,7 @@ import { isStream, labelFor } from 'ember-metal/streams/utils'; export default function subscribe(node, env, scope, stream) { if (!isStream(stream)) { return; } - var component = scope.component; + var component = scope.getComponent(); var unsubscribers = node.streamUnsubscribers = node.streamUnsubscribers || []; unsubscribers.push(stream.subscribe(function() {
true
Other
emberjs
ember.js
87190229e133deab859fbc935e8241f8c667936d.json
Implement Template scopes as classes Similar to `meta`, this commit restructures the scope away from pervasive use of `Object.create` into a custom JavaScript object. This has two benefits: 1. We only need a single parent pointer, rather than having every map inherit from its parent map. 2. v8 penalizes us for using `Object.create` by often assuming we are creating something more class-like and eventually blowing up methods that use scopes. Eventually, this scope refactoring will probably replace some of the hooks in HTMLBars.
packages/ember-routing-htmlbars/lib/keywords/closure-action.js
@@ -25,7 +25,7 @@ export default function closureAction(morph, env, scope, params, hash, template, // on-change={{action setName}} // element-space actions look to "controller" then target. Here we only // look to "target". - target = read(scope.self); + target = read(scope.getSelf()); action = read(rawAction); let actionType = typeof action;
true
Other
emberjs
ember.js
87190229e133deab859fbc935e8241f8c667936d.json
Implement Template scopes as classes Similar to `meta`, this commit restructures the scope away from pervasive use of `Object.create` into a custom JavaScript object. This has two benefits: 1. We only need a single parent pointer, rather than having every map inherit from its parent map. 2. v8 penalizes us for using `Object.create` by often assuming we are creating something more class-like and eventually blowing up methods that use scopes. Eventually, this scope refactoring will probably replace some of the hooks in HTMLBars.
packages/ember-routing-htmlbars/lib/keywords/element-action.js
@@ -32,7 +32,7 @@ export default { target = read(hash.target); } } else { - target = read(scope.locals.controller) || read(scope.self); + target = read(scope.getLocal('controller')) || read(scope.getSelf()); } return { actionName, actionArgs, target };
true
Other
emberjs
ember.js
87190229e133deab859fbc935e8241f8c667936d.json
Implement Template scopes as classes Similar to `meta`, this commit restructures the scope away from pervasive use of `Object.create` into a custom JavaScript object. This has two benefits: 1. We only need a single parent pointer, rather than having every map inherit from its parent map. 2. v8 penalizes us for using `Object.create` by often assuming we are creating something more class-like and eventually blowing up methods that use scopes. Eventually, this scope refactoring will probably replace some of the hooks in HTMLBars.
packages/ember-routing-htmlbars/lib/keywords/render.js
@@ -185,7 +185,7 @@ export default { controllerFullName = 'controller:' + controllerName; } - var parentController = read(scope.locals.controller); + var parentController = read(scope.getLocal('controller')); var controller; // choose name
true
Other
emberjs
ember.js
87694af87d7decf2fcbc52d646138a2f7cfe4cdb.json
Remove most of AttrsProxy Previously, we tried to restrict which attributes we set eagerly, and clean up the rest using unknownProperty. However, over time, making that work correctly has gotten more and more complicated, and the cost of the laziness is more than the benefits. This commit goes back to an eager setting strategy, eliminates unknownProperty and the reliance on _internalDidReceiveAttrs. It leaves a setter interceptor for propagating sets to mutable cells.
packages/ember-htmlbars/lib/node-managers/component-node-manager.js
@@ -221,6 +221,10 @@ ComponentNodeManager.prototype.rerender = function(_env, attrs, visitor) { var snapshot = takeSnapshot(attrs); if (component._renderNode.shouldReceiveAttrs) { + if (component.propagateAttrsToThis) { + component.propagateAttrsToThis(takeLegacySnapshot(attrs)); + } + env.renderer.componentUpdateAttrs(component, snapshot); component._renderNode.shouldReceiveAttrs = false; } @@ -258,11 +262,9 @@ export function createComponent(_component, isAngleBracket, _props, renderNode, props.attrs = snapshot; if (!isAngleBracket) { - let proto = _component.proto(); - assert('controller= is no longer supported', !('controller' in attrs)); - mergeBindings(props, shadowedAttrs(proto, snapshot)); + mergeBindings(props, snapshot); } else { props._isAngleBracket = true; } @@ -289,28 +291,21 @@ export function createComponent(_component, isAngleBracket, _props, renderNode, return component; } -function shadowedAttrs(target, attrs) { - let shadowed = {}; - - // For backwards compatibility, set the component property - // if it has an attr with that name. Undefined attributes - // are handled on demand via the `unknownProperty` hook. - for (var attr in attrs) { - if (attr in target) { - // TODO: Should we issue a deprecation here? - // deprecate(deprecation(attr)); - shadowed[attr] = attrs[attr]; - } +function takeSnapshot(attrs) { + let hash = {}; + + for (var prop in attrs) { + hash[prop] = getCellOrValue(attrs[prop]); } - return shadowed; + return hash; } -function takeSnapshot(attrs) { +export function takeLegacySnapshot(attrs) { let hash = {}; for (var prop in attrs) { - hash[prop] = getCellOrValue(attrs[prop]); + hash[prop] = getValue(attrs[prop]); } return hash;
true
Other
emberjs
ember.js
87694af87d7decf2fcbc52d646138a2f7cfe4cdb.json
Remove most of AttrsProxy Previously, we tried to restrict which attributes we set eagerly, and clean up the rest using unknownProperty. However, over time, making that work correctly has gotten more and more complicated, and the cost of the laziness is more than the benefits. This commit goes back to an eager setting strategy, eliminates unknownProperty and the reliance on _internalDidReceiveAttrs. It leaves a setter interceptor for propagating sets to mutable cells.
packages/ember-htmlbars/lib/node-managers/view-node-manager.js
@@ -8,6 +8,7 @@ import View from 'ember-views/views/view'; import { MUTABLE_CELL } from 'ember-views/compat/attrs-proxy'; import getCellOrValue from 'ember-htmlbars/hooks/get-cell-or-value'; import { instrument } from 'ember-htmlbars/system/instrumentation-support'; +import { takeLegacySnapshot } from 'ember-htmlbars/node-managers/component-node-manager'; // In theory this should come through the env, but it should // be safe to import this until we make the hook system public @@ -122,6 +123,10 @@ ViewNodeManager.prototype.rerender = function(env, attrs, visitor) { env.renderer.willUpdate(component, snapshot); if (component._renderNode.shouldReceiveAttrs) { + if (component.propagateAttrsToThis) { + component.propagateAttrsToThis(takeLegacySnapshot(attrs)); + } + env.renderer.componentUpdateAttrs(component, snapshot); component._renderNode.shouldReceiveAttrs = false; } @@ -171,7 +176,7 @@ export function createOrUpdateComponent(component, options, createOptions, rende merge(props, createOptions); } - mergeBindings(props, shadowedAttrs(proto, snapshot)); + mergeBindings(props, snapshot); props.container = options.parentView ? options.parentView.container : env.container; props.renderer = options.parentView ? options.parentView.renderer : props.container && props.container.lookup('renderer:-dom'); props._viewRegistry = options.parentView ? options.parentView._viewRegistry : props.container && props.container.lookup('-view-registry:main'); @@ -184,6 +189,10 @@ export function createOrUpdateComponent(component, options, createOptions, rende } else { env.renderer.componentUpdateAttrs(component, snapshot); setProperties(component, props); + + if (component.propagateAttrsToThis) { + component.propagateAttrsToThis(takeLegacySnapshot(attrs)); + } } if (options.parentView) { @@ -200,23 +209,6 @@ export function createOrUpdateComponent(component, options, createOptions, rende return component; } -function shadowedAttrs(target, attrs) { - let shadowed = {}; - - // For backwards compatibility, set the component property - // if it has an attr with that name. Undefined attributes - // are handled on demand via the `unknownProperty` hook. - for (var attr in attrs) { - if (attr in target) { - // TODO: Should we issue a deprecation here? - // deprecate(deprecation(attr)); - shadowed[attr] = attrs[attr]; - } - } - - return shadowed; -} - function takeSnapshot(attrs) { let hash = {};
true
Other
emberjs
ember.js
87694af87d7decf2fcbc52d646138a2f7cfe4cdb.json
Remove most of AttrsProxy Previously, we tried to restrict which attributes we set eagerly, and clean up the rest using unknownProperty. However, over time, making that work correctly has gotten more and more complicated, and the cost of the laziness is more than the benefits. This commit goes back to an eager setting strategy, eliminates unknownProperty and the reliance on _internalDidReceiveAttrs. It leaves a setter interceptor for propagating sets to mutable cells.
packages/ember-metal-views/lib/renderer.js
@@ -147,8 +147,6 @@ Renderer.prototype.setAttrs = function (view, attrs) { }; // set attrs the first time Renderer.prototype.componentInitAttrs = function (component, attrs) { - // for attrs-proxy support - component.trigger('_internalDidReceiveAttrs'); component.trigger('didInitAttrs', { attrs }); component.trigger('didReceiveAttrs', { newAttrs: attrs }); }; // set attrs the first time @@ -183,8 +181,6 @@ Renderer.prototype.componentUpdateAttrs = function (component, newAttrs) { set(component, 'attrs', newAttrs); } - // for attrs-proxy support - component.trigger('_internalDidReceiveAttrs'); component.trigger('didUpdateAttrs', { oldAttrs, newAttrs }); component.trigger('didReceiveAttrs', { oldAttrs, newAttrs }); };
true
Other
emberjs
ember.js
87694af87d7decf2fcbc52d646138a2f7cfe4cdb.json
Remove most of AttrsProxy Previously, we tried to restrict which attributes we set eagerly, and clean up the rest using unknownProperty. However, over time, making that work correctly has gotten more and more complicated, and the cost of the laziness is more than the benefits. This commit goes back to an eager setting strategy, eliminates unknownProperty and the reliance on _internalDidReceiveAttrs. It leaves a setter interceptor for propagating sets to mutable cells.
packages/ember-views/lib/compat/attrs-proxy.js
@@ -1,8 +1,6 @@ import { Mixin } from 'ember-metal/mixin'; import { symbol } from 'ember-metal/utils'; import { PROPERTY_DID_CHANGE } from 'ember-metal/property_events'; -import { on } from 'ember-metal/events'; -import EmptyObject from 'ember-metal/empty_object'; export function deprecation(key) { return `You tried to look up an attribute directly on the component. This is deprecated. Use attrs.${key} instead.`; @@ -14,37 +12,9 @@ function isCell(val) { return val && val[MUTABLE_CELL]; } -function setupAvoidPropagating(instance) { - // This caches the list of properties to avoid setting onto the component instance - // inside `_propagateAttrsToThis`. We cache them so that every instantiated component - // does not have to pay the calculation penalty. - let constructor = instance.constructor; - if (!constructor.__avoidPropagating) { - constructor.__avoidPropagating = new EmptyObject(); - let i, l; - for (i = 0, l = instance.concatenatedProperties.length; i < l; i++) { - let prop = instance.concatenatedProperties[i]; - - constructor.__avoidPropagating[prop] = true; - } - - for (i = 0, l = instance.mergedProperties.length; i < l; i++) { - let prop = instance.mergedProperties[i]; - - constructor.__avoidPropagating[prop] = true; - } - } -} - let AttrsProxyMixin = { attrs: null, - init() { - this._super(...arguments); - - setupAvoidPropagating(this); - }, - getAttr(key) { let attrs = this.attrs; if (!attrs) { return; } @@ -67,50 +37,11 @@ let AttrsProxyMixin = { val.update(value); }, - _propagateAttrsToThis() { - let attrs = this.attrs; - - for (let prop in attrs) { - if (prop !== 'attrs' && !this.constructor.__avoidPropagating[prop]) { - this.set(prop, this.getAttr(prop)); - } - } - }, - - initializeShape: on('init', function() { - this._isDispatchingAttrs = false; - }), - - _internalDidReceiveAttrs() { - this._super(); + propagateAttrsToThis(attrs) { this._isDispatchingAttrs = true; - this._propagateAttrsToThis(); + this.setProperties(attrs); this._isDispatchingAttrs = false; - }, - - - unknownProperty(key) { - if (this._isAngleBracket) { return; } - - var attrs = this.attrs; - - if (attrs && key in attrs) { - // do not deprecate accessing `this[key]` at this time. - // add this back when we have a proper migration path - // deprecate(deprecation(key), { id: 'ember-views.', until: '3.0.0' }); - let possibleCell = attrs[key]; - - if (possibleCell && possibleCell[MUTABLE_CELL]) { - return possibleCell.value; - } - - return possibleCell; - } } - - //setUnknownProperty(key) { - - //} }; AttrsProxyMixin[PROPERTY_DID_CHANGE] = function(key) {
true
Other
emberjs
ember.js
41d0162fdca4d71212977b0337f47ac8afab5464.json
fix hasDeps inheritance
packages/ember-metal/lib/meta.js
@@ -194,8 +194,14 @@ function inheritedMapOfMaps(name, Meta) { }; Meta.prototype['has' + capitalized] = function(subkey) { - let map = this._getInherited(key); - return map && !!map[subkey]; + let pointer = this; + while (pointer !== undefined) { + if (pointer[key] && pointer[key][subkey]) { + return true; + } + pointer = pointer.parent; + } + return false; }; Meta.prototype['forEachIn' + capitalized] = function(subkey, fn) {
false
Other
emberjs
ember.js
c3dd592c27ab4769be6b7a1f06d75b81b72296eb.json
Remove work around for babel bug.
packages/ember-metal/lib/watch_key.js
@@ -58,10 +58,6 @@ if (isEnabled('mandatory-setter')) { }; } -// This is super annoying, but required until -// https://github.com/babel/babel/issues/906 is resolved -; // jshint ignore:line - export function unwatchKey(obj, keyName, meta) { var m = meta || metaFor(obj); let count = m.peekWatching(keyName);
false
Other
emberjs
ember.js
2a44c09675932f2fc12152db3973e5b6ab1f29d3.json
Update HTMLBars to v0.14.4.
package.json
@@ -33,7 +33,7 @@ "finalhandler": "^0.4.0", "github": "^0.2.3", "glob": "~4.3.2", - "htmlbars": "0.14.3", + "htmlbars": "0.14.4", "qunit-extras": "^1.3.0", "qunitjs": "^1.16.0", "route-recognizer": "0.1.5",
false
Other
emberjs
ember.js
3439ccd2bfbe76cbddfd1416afbbec791f920a52.json
Remove unused conditional stream.
packages/ember-metal/lib/streams/conditional.js
@@ -1,52 +0,0 @@ -import Stream from 'ember-metal/streams/stream'; -import { - read, - subscribe, - unsubscribe, - isStream -} from 'ember-metal/streams/utils'; - -export default function conditional(test, consequent, alternate) { - if (isStream(test)) { - return new ConditionalStream(test, consequent, alternate); - } else { - if (test) { - return consequent; - } else { - return alternate; - } - } -} - -function ConditionalStream(test, consequent, alternate) { - this.init(); - - this.oldTestResult = undefined; - this.test = test; - this.consequent = consequent; - this.alternate = alternate; -} - -ConditionalStream.prototype = Object.create(Stream.prototype); - -ConditionalStream.prototype.compute = function() { - var oldTestResult = this.oldTestResult; - var newTestResult = !!read(this.test); - - if (newTestResult !== oldTestResult) { - switch (oldTestResult) { - case true: unsubscribe(this.consequent, this.notify, this); break; - case false: unsubscribe(this.alternate, this.notify, this); break; - case undefined: subscribe(this.test, this.notify, this); - } - - switch (newTestResult) { - case true: subscribe(this.consequent, this.notify, this); break; - case false: subscribe(this.alternate, this.notify, this); - } - - this.oldTestResult = newTestResult; - } - - return newTestResult ? read(this.consequent) : read(this.alternate); -};
false
Other
emberjs
ember.js
c8c0fc88e9b04065addfcd45919867b7fcf99725.json
Add new-stream util Use new-stream util to remove duplication
packages/ember-htmlbars/lib/hooks/bind-self.js
@@ -3,8 +3,7 @@ @submodule ember-htmlbars */ -import ProxyStream from 'ember-metal/streams/proxy-stream'; -import subscribe from 'ember-htmlbars/utils/subscribe'; +import newStream from 'ember-htmlbars/utils/new-stream'; export default function bindSelf(env, scope, _self) { let self = _self; @@ -35,9 +34,3 @@ export default function bindSelf(env, scope, _self) { scope.locals.controller = scope.self; } } - -function newStream(scope, key, newValue, renderNode, isSelf) { - var stream = new ProxyStream(newValue, isSelf ? '' : key); - if (renderNode) { subscribe(renderNode, scope, stream); } - scope[key] = stream; -}
true
Other
emberjs
ember.js
c8c0fc88e9b04065addfcd45919867b7fcf99725.json
Add new-stream util Use new-stream util to remove duplication
packages/ember-htmlbars/lib/hooks/bind-shadow-scope.js
@@ -3,6 +3,8 @@ @submodule ember-htmlbars */ +import newStream from 'ember-htmlbars/utils/new-stream'; + export default function bindShadowScope(env, parentScope, shadowScope, options) { if (!options) { return; } @@ -38,12 +40,3 @@ export default function bindShadowScope(env, parentScope, shadowScope, options) return shadowScope; } - -import ProxyStream from 'ember-metal/streams/proxy-stream'; -import subscribe from 'ember-htmlbars/utils/subscribe'; - -function newStream(scope, key, newValue, renderNode, isSelf) { - var stream = new ProxyStream(newValue, isSelf ? '' : key); - if (renderNode) { subscribe(renderNode, scope, stream); } - scope[key] = stream; -}
true
Other
emberjs
ember.js
c8c0fc88e9b04065addfcd45919867b7fcf99725.json
Add new-stream util Use new-stream util to remove duplication
packages/ember-htmlbars/lib/utils/new-stream.js
@@ -0,0 +1,8 @@ +import ProxyStream from 'ember-metal/streams/proxy-stream'; +import subscribe from 'ember-htmlbars/utils/subscribe'; + +export default function newStream(scope, key, newValue, renderNode, isSelf) { + var stream = new ProxyStream(newValue, isSelf ? '' : key); + if (renderNode) { subscribe(renderNode, scope, stream); } + scope[key] = stream; +}
true
Other
emberjs
ember.js
23888dac5efdb7fb043d9a1ee6560495d74ecef4.json
Remove knownForType usage for dashless helpers. `container.registry.has` is a fast check, and allows us to make this PAYGO much better than iterating all modules up front.
packages/ember-htmlbars/lib/hooks/has-helper.js
@@ -6,7 +6,7 @@ export default function hasHelperHook(env, scope, helperName) { } var container = env.container; - if (validateLazyHelperName(helperName, container, env.hooks.keywords, env.knownHelpers)) { + if (validateLazyHelperName(helperName, container, env.hooks.keywords)) { var containerName = 'helper:' + helperName; if (container.registry.has(containerName)) { return true;
true
Other
emberjs
ember.js
23888dac5efdb7fb043d9a1ee6560495d74ecef4.json
Remove knownForType usage for dashless helpers. `container.registry.has` is a fast check, and allows us to make this PAYGO much better than iterating all modules up front.
packages/ember-htmlbars/lib/system/discover-known-helpers.js
@@ -1,22 +0,0 @@ -import dictionary from 'ember-metal/dictionary'; - -export default function discoverKnownHelpers(container) { - let registry = container && container.registry; - let helpers = dictionary(null); - - if (!registry) { - return helpers; - } - - let known = registry.knownForType('helper'); - let knownContainerKeys = Object.keys(known); - - for (let index = 0, length = knownContainerKeys.length; index < length; index++) { - let fullName = knownContainerKeys[index]; - let name = fullName.slice(7); // remove `helper:` from fullName - - helpers[name] = true; - } - - return helpers; -}
true
Other
emberjs
ember.js
23888dac5efdb7fb043d9a1ee6560495d74ecef4.json
Remove knownForType usage for dashless helpers. `container.registry.has` is a fast check, and allows us to make this PAYGO much better than iterating all modules up front.
packages/ember-htmlbars/lib/system/lookup-helper.js
@@ -10,14 +10,8 @@ export var CONTAINS_DASH_CACHE = new Cache(1000, function(key) { return key.indexOf('-') !== -1; }); -export function validateLazyHelperName(helperName, container, keywords, knownHelpers) { - if (!container || (helperName in keywords)) { - return false; - } - - if (knownHelpers[helperName] || CONTAINS_DASH_CACHE.get(helperName)) { - return true; - } +export function validateLazyHelperName(helperName, container, keywords) { + return container && !(helperName in keywords); } /** @@ -39,7 +33,7 @@ export function findHelper(name, view, env) { if (!helper) { var container = env.container; - if (validateLazyHelperName(name, container, env.hooks.keywords, env.knownHelpers)) { + if (validateLazyHelperName(name, container, env.hooks.keywords)) { var helperName = 'helper:' + name; if (container.registry.has(helperName)) { helper = container.lookupFactory(helperName);
true
Other
emberjs
ember.js
23888dac5efdb7fb043d9a1ee6560495d74ecef4.json
Remove knownForType usage for dashless helpers. `container.registry.has` is a fast check, and allows us to make this PAYGO much better than iterating all modules up front.
packages/ember-htmlbars/lib/system/render-env.js
@@ -1,5 +1,4 @@ import defaultEnv from 'ember-htmlbars/env'; -import discoverKnownHelpers from 'ember-htmlbars/system/discover-known-helpers'; export default function RenderEnv(options) { this.lifecycleHooks = options.lifecycleHooks || []; @@ -12,7 +11,6 @@ export default function RenderEnv(options) { this.container = options.container; this.renderer = options.renderer; this.dom = options.dom; - this.knownHelpers = options.knownHelpers || discoverKnownHelpers(options.container); this.hooks = defaultEnv.hooks; this.helpers = defaultEnv.helpers; @@ -40,8 +38,7 @@ RenderEnv.prototype.childWithView = function(view) { lifecycleHooks: this.lifecycleHooks, renderedViews: this.renderedViews, renderedNodes: this.renderedNodes, - hasParentOutlet: this.hasParentOutlet, - knownHelpers: this.knownHelpers + hasParentOutlet: this.hasParentOutlet }); }; @@ -55,7 +52,6 @@ RenderEnv.prototype.childWithOutletState = function(outletState, hasParentOutlet lifecycleHooks: this.lifecycleHooks, renderedViews: this.renderedViews, renderedNodes: this.renderedNodes, - hasParentOutlet: hasParentOutlet, - knownHelpers: this.knownHelpers + hasParentOutlet: hasParentOutlet }); };
true
Other
emberjs
ember.js
23888dac5efdb7fb043d9a1ee6560495d74ecef4.json
Remove knownForType usage for dashless helpers. `container.registry.has` is a fast check, and allows us to make this PAYGO much better than iterating all modules up front.
packages/ember-htmlbars/tests/system/discover-known-helpers-test.js
@@ -1,48 +0,0 @@ -import Registry from 'container/registry'; -import Helper from 'ember-htmlbars/helper'; -import { runDestroy } from 'ember-runtime/tests/utils'; -import discoverKnownHelpers from 'ember-htmlbars/system/discover-known-helpers'; - -var resolver, registry, container; - -QUnit.module('ember-htmlbars: discover-known-helpers', { - setup() { - resolver = function() { }; - - registry = new Registry({ resolver }); - container = registry.container(); - }, - - teardown() { - runDestroy(container); - registry = container = null; - } -}); - -QUnit.test('returns an empty hash when no helpers are known', function() { - let result = discoverKnownHelpers(container); - - deepEqual(result, {}, 'no helpers were known'); -}); - -QUnit.test('includes helpers in the registry', function() { - registry.register('helper:t', Helper); - let result = discoverKnownHelpers(container); - let helpers = Object.keys(result); - - deepEqual(helpers, ['t'], 'helpers from the registry were known'); -}); - -QUnit.test('includes resolved helpers', function() { - resolver.knownForType = function() { - return { - 'helper:f': true - }; - }; - - registry.register('helper:t', Helper); - let result = discoverKnownHelpers(container); - let helpers = Object.keys(result); - - deepEqual(helpers, ['t', 'f'], 'helpers from the registry were known'); -});
true
Other
emberjs
ember.js
0192fdb93500ef6b80ea8b8a11c818e9a6136525.json
Update emberjs-build to remove need for derequire. emberjs-build now uses a babel plugin to transform top level `define` calls into `enifed` calls. This allows us to: * keep dev builds closer to prod builds (by removing this specific difference) * shave another 3-5 seconds off of production builds. ``` % ember s -prod Before: initial build, cold boot: Build successful - 86282ms. initial build, warm boot: Build successful - 19390ms. After: initial build, cold boot: Build successful - 61330ms. initial build, warm boot: Build successful - 13912ms. ```
package.json
@@ -28,7 +28,7 @@ "ember-cli-sauce": "^1.3.0", "ember-cli-yuidoc": "0.7.0", "ember-publisher": "0.0.7", - "emberjs-build": "0.3.5", + "emberjs-build": "0.4.0", "express": "^4.5.0", "finalhandler": "^0.4.0", "github": "^0.2.3",
true
Other
emberjs
ember.js
0192fdb93500ef6b80ea8b8a11c818e9a6136525.json
Update emberjs-build to remove need for derequire. emberjs-build now uses a babel plugin to transform top level `define` calls into `enifed` calls. This allows us to: * keep dev builds closer to prod builds (by removing this specific difference) * shave another 3-5 seconds off of production builds. ``` % ember s -prod Before: initial build, cold boot: Build successful - 86282ms. initial build, warm boot: Build successful - 19390ms. After: initial build, cold boot: Build successful - 61330ms. initial build, warm boot: Build successful - 13912ms. ```
packages/loader/lib/main.js
@@ -1,4 +1,4 @@ -var define, requireModule, require, requirejs, Ember; +var enifed, requireModule, require, requirejs, Ember; var mainContext = this; (function() { @@ -15,7 +15,7 @@ var mainContext = this; var registry = {}; var seen = {}; - define = function(name, deps, callback) { + enifed = function(name, deps, callback) { var value = { }; if (!callback) { @@ -72,12 +72,12 @@ var mainContext = this; requirejs._eak_seen = registry; Ember.__loader = { - define: define, + define: enifed, require: require, registry: registry }; } else { - define = Ember.__loader.define; + enifed = Ember.__loader.define; requirejs = require = requireModule = Ember.__loader.require; } })();
true
Other
emberjs
ember.js
9869cc29c1e01b01a22f115fd1939e6ef18e7d67.json
Update emberjs-build to remove use-strict-remover. This has been implemented upstream as a custom babel plugin.
package.json
@@ -28,7 +28,7 @@ "ember-cli-sauce": "^1.3.0", "ember-cli-yuidoc": "0.7.0", "ember-publisher": "0.0.7", - "emberjs-build": "0.3.3", + "emberjs-build": "0.3.5", "express": "^4.5.0", "finalhandler": "^0.4.0", "github": "^0.2.3",
true
Other
emberjs
ember.js
9869cc29c1e01b01a22f115fd1939e6ef18e7d67.json
Update emberjs-build to remove use-strict-remover. This has been implemented upstream as a custom babel plugin.
packages/ember-metal/lib/dependent_keys.js
@@ -1,7 +1,6 @@ +'no use strict'; // Remove "use strict"; from transpiled module until // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed -// -'REMOVE_USE_STRICT: true'; import { watch,
true
Other
emberjs
ember.js
9869cc29c1e01b01a22f115fd1939e6ef18e7d67.json
Update emberjs-build to remove use-strict-remover. This has been implemented upstream as a custom babel plugin.
packages/ember-metal/lib/events.js
@@ -1,7 +1,6 @@ +'no use strict'; // Remove "use strict"; from transpiled module until // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed -// -'REMOVE_USE_STRICT: true'; /** @module ember
true
Other
emberjs
ember.js
9869cc29c1e01b01a22f115fd1939e6ef18e7d67.json
Update emberjs-build to remove use-strict-remover. This has been implemented upstream as a custom babel plugin.
packages/ember-metal/lib/meta.js
@@ -1,7 +1,6 @@ +'no use strict'; // Remove "use strict"; from transpiled module until // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed -// -'REMOVE_USE_STRICT: true'; import { protoMethods as listenerMethods } from 'ember-metal/meta_listeners'; import EmptyObject from 'ember-metal/empty_object';
true
Other
emberjs
ember.js
9869cc29c1e01b01a22f115fd1939e6ef18e7d67.json
Update emberjs-build to remove use-strict-remover. This has been implemented upstream as a custom babel plugin.
packages/ember-metal/lib/mixin.js
@@ -1,7 +1,6 @@ +'no use strict'; // Remove "use strict"; from transpiled module until // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed -// -'REMOVE_USE_STRICT: true'; /** @module ember
true
Other
emberjs
ember.js
9869cc29c1e01b01a22f115fd1939e6ef18e7d67.json
Update emberjs-build to remove use-strict-remover. This has been implemented upstream as a custom babel plugin.
packages/ember-metal/lib/utils.js
@@ -1,7 +1,6 @@ +'no use strict'; // Remove "use strict"; from transpiled module until // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed -// -'REMOVE_USE_STRICT: true'; /** @module ember-metal
true
Other
emberjs
ember.js
9869cc29c1e01b01a22f115fd1939e6ef18e7d67.json
Update emberjs-build to remove use-strict-remover. This has been implemented upstream as a custom babel plugin.
packages/ember-runtime/lib/system/core_object.js
@@ -1,7 +1,6 @@ +'no use strict'; // Remove "use strict"; from transpiled module until // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed -// -'REMOVE_USE_STRICT: true'; /** @module ember
true
Other
emberjs
ember.js
ab3159a8359b2b703395436000424e269d5bded4.json
Update emberjs-build to remove loader recursion. Should help initial boot a tiny bit, but is less bytes either way :smiley:.
package.json
@@ -28,7 +28,7 @@ "ember-cli-sauce": "^1.3.0", "ember-cli-yuidoc": "0.7.0", "ember-publisher": "0.0.7", - "emberjs-build": "0.3.2", + "emberjs-build": "0.3.3", "express": "^4.5.0", "finalhandler": "^0.4.0", "github": "^0.2.3",
true
Other
emberjs
ember.js
ab3159a8359b2b703395436000424e269d5bded4.json
Update emberjs-build to remove loader recursion. Should help initial boot a tiny bit, but is less bytes either way :smiley:.
packages/loader/lib/main.js
@@ -60,7 +60,7 @@ var mainContext = this; if (deps[i] === 'exports') { reified.push(exports); } else { - reified.push(internalRequire(resolve(deps[i], name), name)); + reified.push(internalRequire(deps[i], name)); } } @@ -69,28 +69,6 @@ var mainContext = this; return exports; }; - function resolve(child, name) { - if (child.charAt(0) !== '.') { - return child; - } - var parts = child.split('/'); - var parentBase = name.split('/').slice(0, -1); - - for (var i = 0, l = parts.length; i < l; i++) { - var part = parts[i]; - - if (part === '..') { - parentBase.pop(); - } else if (part === '.') { - continue; - } else { - parentBase.push(part); - } - } - - return parentBase.join('/'); - } - requirejs._eak_seen = registry; Ember.__loader = {
true
Other
emberjs
ember.js
def813cd5f8d7d73f62f054305dcfe7135b4a2c4.json
Add info to debug functions
Brocfile.js
@@ -35,7 +35,7 @@ function babelConfigFor(environment) { if (isProduction) { plugins.push(filterImports({ - 'ember-metal/debug': ['assert','debug','deprecate','runInDebug','warn'] + 'ember-metal/debug': ['assert','debug','deprecate','info','runInDebug','warn'] })); }
true
Other
emberjs
ember.js
def813cd5f8d7d73f62f054305dcfe7135b4a2c4.json
Add info to debug functions
features.json
@@ -10,8 +10,5 @@ "ember-registry-container-reform": true, "ember-routing-routable-components": null }, - "debugStatements": [ - "Ember.Logger.info", - "Ember.default.Logger.info" - ] + "debugStatements": [] }
true
Other
emberjs
ember.js
def813cd5f8d7d73f62f054305dcfe7135b4a2c4.json
Add info to debug functions
packages/ember-application/lib/system/resolver.js
@@ -4,9 +4,8 @@ */ import Ember from 'ember-metal/core'; -import { assert } from 'ember-metal/debug'; +import { assert, info } from 'ember-metal/debug'; import { get } from 'ember-metal/property_get'; -import Logger from 'ember-metal/logger'; import { classify, capitalize, @@ -431,7 +430,7 @@ export default EmberObject.extend({ padding = new Array(60 - parsedName.fullName.length).join('.'); } - Logger.info(symbol, parsedName.fullName, padding, this.lookupDescription(parsedName.fullName)); + info(symbol, parsedName.fullName, padding, this.lookupDescription(parsedName.fullName)); }, /**
true
Other
emberjs
ember.js
def813cd5f8d7d73f62f054305dcfe7135b4a2c4.json
Add info to debug functions
packages/ember-application/tests/system/dependency_injection/default_resolver_test.js
@@ -1,6 +1,7 @@ +/* globals EmberDev */ import Ember from 'ember-metal/core'; // Ember.TEMPLATES +import { getDebugFunction, setDebugFunction } from 'ember-metal/debug'; import run from 'ember-metal/run_loop'; -import Logger from 'ember-metal/logger'; import Controller from 'ember-runtime/controllers/controller'; import Route from 'ember-routing/system/route'; import Component from 'ember-views/components/component'; @@ -15,7 +16,7 @@ import { registerHelper } from 'ember-htmlbars/helpers'; -var registry, locator, application, originalLookup, originalLoggerInfo; +var registry, locator, application, originalLookup, originalInfo; QUnit.module('Ember.Application Dependency Injection - default resolver', { setup() { @@ -24,7 +25,7 @@ QUnit.module('Ember.Application Dependency Injection - default resolver', { registry = application.__registry__; locator = application.__container__; - originalLoggerInfo = Logger.info; + originalInfo = getDebugFunction('info'); }, teardown() { @@ -34,7 +35,7 @@ QUnit.module('Ember.Application Dependency Injection - default resolver', { var UserInterfaceNamespace = Namespace.NAMESPACES_BY_ID['UserInterface']; if (UserInterfaceNamespace) { run(UserInterfaceNamespace, 'destroy'); } - Logger.info = originalLoggerInfo; + setDebugFunction('info', originalInfo); } }); @@ -158,44 +159,59 @@ QUnit.test('the default resolver throws an error if the fullName to resolve is i }); QUnit.test('the default resolver logs hits if `LOG_RESOLVER` is set', function() { + if (EmberDev && EmberDev.runningProdBuild) { + ok(true, 'Logging does not occur in production builds'); + return; + } + expect(3); application.LOG_RESOLVER = true; application.ScoobyDoo = EmberObject.extend(); application.toString = function() { return 'App'; }; - Logger.info = function(symbol, name, padding, lookupDescription) { + setDebugFunction('info', function(symbol, name, padding, lookupDescription) { equal(symbol, '[✓]', 'proper symbol is printed when a module is found'); equal(name, 'doo:scooby', 'proper lookup value is logged'); equal(lookupDescription, 'App.ScoobyDoo'); - }; + }); registry.resolve('doo:scooby'); }); QUnit.test('the default resolver logs misses if `LOG_RESOLVER` is set', function() { + if (EmberDev && EmberDev.runningProdBuild) { + ok(true, 'Logging does not occur in production builds'); + return; + } + expect(3); application.LOG_RESOLVER = true; application.toString = function() { return 'App'; }; - Logger.info = function(symbol, name, padding, lookupDescription) { + setDebugFunction('info', function(symbol, name, padding, lookupDescription) { equal(symbol, '[ ]', 'proper symbol is printed when a module is not found'); equal(name, 'doo:scooby', 'proper lookup value is logged'); equal(lookupDescription, 'App.ScoobyDoo'); - }; + }); registry.resolve('doo:scooby'); }); QUnit.test('doesn\'t log without LOG_RESOLVER', function() { + if (EmberDev && EmberDev.runningProdBuild) { + ok(true, 'Logging does not occur in production builds'); + return; + } + var infoCount = 0; application.ScoobyDoo = EmberObject.extend(); - Logger.info = function(symbol, name) { + setDebugFunction('info', function(symbol, name) { infoCount = infoCount + 1; - }; + }); registry.resolve('doo:scooby'); registry.resolve('doo:scrappy');
true
Other
emberjs
ember.js
def813cd5f8d7d73f62f054305dcfe7135b4a2c4.json
Add info to debug functions
packages/ember-debug/lib/main.js
@@ -79,6 +79,16 @@ setDebugFunction('debug', function debug(message) { Logger.debug('DEBUG: ' + message); }); +/** + Display an info notice. + + @method info + @private +*/ +setDebugFunction('info', function info() { + Logger.info.apply(undefined, arguments); +}); + /** Alias an old, deprecated method with its new counterpart.
true
Other
emberjs
ember.js
def813cd5f8d7d73f62f054305dcfe7135b4a2c4.json
Add info to debug functions
packages/ember-htmlbars/lib/keywords/debugger.js
@@ -4,7 +4,8 @@ @module ember @submodule ember-htmlbars */ -import Logger from 'ember-metal/logger'; + +import { info } from 'ember-metal/debug'; /** Execute the `debugger` statement in the current template's context. @@ -58,7 +59,7 @@ export default function debuggerKeyword(morph, env, scope) { return env.hooks.getValue(env.hooks.get(env, scope, path)); } - Logger.info('Use `view`, `context`, and `get(<path>)` to debug this template.'); + info('Use `view`, `context`, and `get(<path>)` to debug this template.'); debugger;
true
Other
emberjs
ember.js
def813cd5f8d7d73f62f054305dcfe7135b4a2c4.json
Add info to debug functions
packages/ember-htmlbars/lib/keywords/outlet.js
@@ -3,7 +3,7 @@ @submodule ember-templates */ -import Ember from 'ember-metal/core'; +import { info } from 'ember-metal/debug'; import { get } from 'ember-metal/property_get'; import ViewNodeManager from 'ember-htmlbars/node-managers/view-node-manager'; import topLevelViewTemplate from 'ember-htmlbars/templates/top-level-view'; @@ -141,7 +141,7 @@ export default { template = template || toRender.template && toRender.template.raw; if (LOG_VIEW_LOOKUPS && ViewClass) { - Ember.Logger.info('Rendering ' + toRender.name + ' with ' + ViewClass, { fullName: 'view:' + toRender.name }); + info('Rendering ' + toRender.name + ' with ' + ViewClass, { fullName: 'view:' + toRender.name }); } }
true
Other
emberjs
ember.js
def813cd5f8d7d73f62f054305dcfe7135b4a2c4.json
Add info to debug functions
packages/ember-metal/lib/debug.js
@@ -1,5 +1,6 @@ export let debugFunctions = { assert() {}, + info() {}, warn() {}, debug() {}, deprecate() {}, @@ -19,6 +20,10 @@ export function assert() { return debugFunctions.assert.apply(undefined, arguments); } +export function info() { + return debugFunctions.info.apply(undefined, arguments); +} + export function warn() { return debugFunctions.warn.apply(undefined, arguments); }
true
Other
emberjs
ember.js
def813cd5f8d7d73f62f054305dcfe7135b4a2c4.json
Add info to debug functions
packages/ember-routing/lib/system/generate_controller.js
@@ -1,4 +1,4 @@ -import Ember from 'ember-metal/core'; // Logger +import { info } from 'ember-metal/debug'; import { get } from 'ember-metal/property_get'; /** @@ -51,7 +51,7 @@ export default function generateController(container, controllerName, context) { var instance = container.lookup(fullName); if (get(instance, 'namespace.LOG_ACTIVE_GENERATION')) { - Ember.Logger.info(`generated -> ${fullName}`, { fullName: fullName }); + info(`generated -> ${fullName}`, { fullName: fullName }); } return instance;
true
Other
emberjs
ember.js
def813cd5f8d7d73f62f054305dcfe7135b4a2c4.json
Add info to debug functions
packages/ember-routing/lib/system/route.js
@@ -1,5 +1,5 @@ import Ember from 'ember-metal/core'; // FEATURES, A, deprecate, assert, Logger -import { assert, deprecate } from 'ember-metal/debug'; +import { assert, deprecate, info } from 'ember-metal/debug'; import isEnabled from 'ember-metal/features'; import EmberError from 'ember-metal/error'; import { get } from 'ember-metal/property_get'; @@ -2161,7 +2161,7 @@ function buildRenderOptions(route, namePassed, isDefaultRender, name, options) { assert(`Could not find "${name}" template, view, or component.`, isDefaultRender); if (LOG_VIEW_LOOKUPS) { var fullName = `template:${name}`; - Ember.Logger.info(`Could not find "${name}" template or view. Nothing will be rendered`, { fullName: fullName }); + info(`Could not find "${name}" template or view. Nothing will be rendered`, { fullName: fullName }); } }
true
Other
emberjs
ember.js
def813cd5f8d7d73f62f054305dcfe7135b4a2c4.json
Add info to debug functions
packages/ember-routing/lib/system/router.js
@@ -1,5 +1,5 @@ import Ember from 'ember-metal/core'; -import { assert } from 'ember-metal/debug'; +import { assert, info } from 'ember-metal/debug'; import EmberError from 'ember-metal/error'; import { get } from 'ember-metal/property_get'; import { set } from 'ember-metal/property_set'; @@ -503,7 +503,7 @@ var EmberRouter = EmberObject.extend(Evented, { handler = container.lookup(routeName); if (get(this, 'namespace.LOG_ACTIVE_GENERATION')) { - Ember.Logger.info(`generated -> ${routeName}`, { fullName: routeName }); + info(`generated -> ${routeName}`, { fullName: routeName }); } }
true
Other
emberjs
ember.js
824ec132a7cd4e8cd600a85f477244bb3042648e.json
Update router.js in bower.json
bower.json
@@ -12,7 +12,7 @@ "devDependencies": { "backburner": "https://github.com/ebryn/backburner.js.git#ea82b6d703a7b65b4c4c65671843edb8d67f2a6c", "rsvp": "https://github.com/tildeio/rsvp.js.git#3.0.20", - "router.js": "https://github.com/tildeio/router.js.git#ed45bc5c5e055af0ab875ef2c52feda792ee23e4", + "router.js": "https://github.com/tildeio/router.js.git#04b27c911995902b022966f4d29d8686ba7d847c", "dag-map": "https://github.com/krisselden/dag-map.git#e307363256fe918f426e5a646cb5f5062d3245be", "ember-dev": "https://github.com/emberjs/ember-dev.git#c1ac77a57f0eb3b9835dd13dcedd4d72bd902ecf" }
false
Other
emberjs
ember.js
341d25e81532a21e267d86b585aae4dc49ffb1e7.json
Add router.js to yuidoc.json
yuidoc.json
@@ -16,7 +16,8 @@ "packages/ember-application/lib", "packages/ember-testing/lib", "packages/ember-extension-support/lib", - "bower_components/rsvp/lib" + "bower_components/rsvp/lib", + "bower_components/router.js/lib" ], "exclude": "vendor", "outdir": "docs"
false
Other
emberjs
ember.js
847a7869f552ac480a09530b892b71f40450ec74.json
Replace usage of debug statements in ember-debug.
packages/ember-debug/lib/deprecate.js
@@ -3,6 +3,7 @@ import Ember from 'ember-metal/core'; import EmberError from 'ember-metal/error'; import Logger from 'ember-metal/logger'; + import { registerHandler as genericRegisterHandler, invoke } from 'ember-debug/handlers'; export function registerHandler(handler) {
true
Other
emberjs
ember.js
847a7869f552ac480a09530b892b71f40450ec74.json
Replace usage of debug statements in ember-debug.
packages/ember-debug/lib/main.js
@@ -1,13 +1,18 @@ import Ember from 'ember-metal/core'; -import { setDebugFunction } from 'ember-metal/debug'; +import { + warn, + deprecate, + debug, + setDebugFunction +} from 'ember-metal/debug'; import isEnabled, { FEATURES } from 'ember-metal/features'; import EmberError from 'ember-metal/error'; import Logger from 'ember-metal/logger'; import environment from 'ember-metal/environment'; -import deprecate, { +import _deprecate, { registerHandler as registerDeprecationHandler } from 'ember-debug/deprecate'; -import warn, { +import _warn, { registerHandler as registerWarnHandler } from 'ember-debug/warn'; import isPlainFunction from 'ember-debug/is-plain-function'; @@ -44,7 +49,7 @@ import isPlainFunction from 'ember-debug/is-plain-function'; its return value will be used as condition. @public */ -function assert(desc, test) { +setDebugFunction('assert', function assert(desc, test) { var throwAssertion; if (isPlainFunction(test)) { @@ -56,7 +61,7 @@ function assert(desc, test) { if (throwAssertion) { throw new EmberError('Assertion Failed: ' + desc); } -} +}); /** Display a debug notice. Ember build tools will remove any calls to @@ -70,9 +75,9 @@ function assert(desc, test) { @param {String} message A debug message to display. @public */ -function debug(message) { +setDebugFunction('debug', function debug(message) { Logger.debug('DEBUG: ' + message); -} +}); /** Alias an old, deprecated method with its new counterpart. @@ -94,21 +99,21 @@ function debug(message) { @return {Function} a new function that wrapped the original function with a deprecation warning @private */ -function deprecateFunc(...args) { +setDebugFunction('deprecateFunc', function deprecateFunc(...args) { if (args.length === 3) { let [message, options, func] = args; return function() { - Ember.deprecate(message, false, options); + deprecate(message, false, options); return func.apply(this, arguments); }; } else { let [message, func] = args; return function() { - Ember.deprecate(message); + deprecate(message); return func.apply(this, arguments); }; } -} +}); /** @@ -130,17 +135,12 @@ function deprecateFunc(...args) { @since 1.5.0 @public */ -function runInDebug(func) { +setDebugFunction('runInDebug', function runInDebug(func) { func(); -} - -setDebugFunction('assert', assert); -setDebugFunction('warn', warn); -setDebugFunction('debug', debug); -setDebugFunction('deprecate', deprecate); -setDebugFunction('deprecateFunc', deprecateFunc); -setDebugFunction('runInDebug', runInDebug); +}); +setDebugFunction('deprecate', _deprecate); +setDebugFunction('warn', _warn); /** Will call `Ember.warn()` if ENABLE_ALL_FEATURES, ENABLE_OPTIONAL_FEATURES, or any specific FEATURES flag is truthy. @@ -153,12 +153,12 @@ setDebugFunction('runInDebug', runInDebug); */ export function _warnIfUsingStrippedFeatureFlags(FEATURES, featuresWereStripped) { if (featuresWereStripped) { - Ember.warn('Ember.ENV.ENABLE_ALL_FEATURES is only available in canary builds.', !Ember.ENV.ENABLE_ALL_FEATURES, { id: 'ember-debug.feature-flag-with-features-stripped' }); - Ember.warn('Ember.ENV.ENABLE_OPTIONAL_FEATURES is only available in canary builds.', !Ember.ENV.ENABLE_OPTIONAL_FEATURES, { id: 'ember-debug.feature-flag-with-features-stripped' }); + warn('Ember.ENV.ENABLE_ALL_FEATURES is only available in canary builds.', !Ember.ENV.ENABLE_ALL_FEATURES, { id: 'ember-debug.feature-flag-with-features-stripped' }); + warn('Ember.ENV.ENABLE_OPTIONAL_FEATURES is only available in canary builds.', !Ember.ENV.ENABLE_OPTIONAL_FEATURES, { id: 'ember-debug.feature-flag-with-features-stripped' }); for (var key in FEATURES) { if (FEATURES.hasOwnProperty(key) && key !== 'isEnabled') { - Ember.warn('FEATURE["' + key + '"] is set as enabled, but FEATURE flags are only available in canary builds.', !FEATURES[key], { id: 'ember-debug.feature-flag-with-features-stripped' }); + warn('FEATURE["' + key + '"] is set as enabled, but FEATURE flags are only available in canary builds.', !FEATURES[key], { id: 'ember-debug.feature-flag-with-features-stripped' }); } } } @@ -191,7 +191,7 @@ if (!Ember.testing) { downloadURL = 'https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/'; } - Ember.debug('For more advanced debugging, install the Ember Inspector from ' + downloadURL); + debug('For more advanced debugging, install the Ember Inspector from ' + downloadURL); } }, false); } @@ -213,5 +213,5 @@ if (isEnabled('ember-debug-handlers')) { */ export var runningNonEmberDebugJS = false; if (runningNonEmberDebugJS) { - Ember.warn('Please use `ember.debug.js` instead of `ember.js` for development and debugging.'); + warn('Please use `ember.debug.js` instead of `ember.js` for development and debugging.'); }
true
Other
emberjs
ember.js
847a7869f552ac480a09530b892b71f40450ec74.json
Replace usage of debug statements in ember-debug.
packages/ember-debug/lib/warn.js
@@ -1,5 +1,5 @@ -import Ember from 'ember-metal/core'; import Logger from 'ember-metal/logger'; +import { deprecate } from 'ember-metal/debug'; import { registerHandler as genericRegisterHandler, invoke } from 'ember-debug/handlers'; export function registerHandler(handler) { @@ -30,15 +30,15 @@ export let missingOptionsIdDeprecation = 'When calling `Ember.warn` you must pro */ export default function warn(message, test, options) { if (!options) { - Ember.deprecate( + deprecate( missingOptionsDeprecation, false, { id: 'ember-debug.warn-options-missing', until: '3.0.0' } ); } if (options && !options.id) { - Ember.deprecate( + deprecate( missingOptionsIdDeprecation, false, { id: 'ember-debug.warn-id-missing', until: '3.0.0' }
true
Other
emberjs
ember.js
847a7869f552ac480a09530b892b71f40450ec74.json
Replace usage of debug statements in ember-debug.
packages/ember-debug/tests/warn_if_using_stripped_feature_flags_test.js
@@ -1,4 +1,5 @@ import Ember from 'ember-metal/core'; +import { getDebugFunction, setDebugFunction } from 'ember-metal/debug'; import { _warnIfUsingStrippedFeatureFlags } from 'ember-debug'; var oldWarn, oldRunInDebug, origEnvFeatures, origEnableAll, origEnableOptional; @@ -7,15 +8,15 @@ function confirmWarns(expectedMsg) { var featuresWereStripped = true; var FEATURES = Ember.ENV.FEATURES; - Ember.warn = function(msg, test) { + setDebugFunction('warn', function(msg, test) { if (!test) { equal(msg, expectedMsg); } - }; + }); - Ember.runInDebug = function (func) { + setDebugFunction('runInDebug', function (func) { func(); - }; + }); // Should trigger our 1 warning _warnIfUsingStrippedFeatureFlags(FEATURES, featuresWereStripped); @@ -27,16 +28,16 @@ function confirmWarns(expectedMsg) { QUnit.module('ember-debug - _warnIfUsingStrippedFeatureFlags', { setup() { - oldWarn = Ember.warn; - oldRunInDebug = Ember.runInDebug; + oldWarn = getDebugFunction('warn'); + oldRunInDebug = getDebugFunction('runInDebug'); origEnvFeatures = Ember.ENV.FEATURES; origEnableAll = Ember.ENV.ENABLE_ALL_FEATURES; origEnableOptional = Ember.ENV.ENABLE_OPTIONAL_FEATURES; }, teardown() { - Ember.warn = oldWarn; - Ember.runInDebug = oldRunInDebug; + setDebugFunction('warn', oldWarn); + setDebugFunction('runInDebug', oldRunInDebug); Ember.ENV.FEATURES = origEnvFeatures; Ember.ENV.ENABLE_ALL_FEATURES = origEnableAll; Ember.ENV.ENABLE_OPTIONAL_FEATURES = origEnableOptional; @@ -76,4 +77,3 @@ QUnit.test('Enabling a FEATURES flag in non-canary, debug build causes a warning confirmWarns('FEATURE["fred"] is set as enabled, but FEATURE flags are only available in canary builds.'); }); -
true
Other
emberjs
ember.js
505031063e8c4ba096c359506dc979fa2ccfc96a.json
Extract root element class into variable
packages/ember-views/lib/system/event_dispatcher.js
@@ -14,6 +14,9 @@ import ActionManager from 'ember-views/system/action_manager'; import View from 'ember-views/views/view'; import assign from 'ember-metal/assign'; +let ROOT_ELEMENT_CLASS = 'ember-application'; +let ROOT_ELEMENT_SELECTOR = '.' + ROOT_ELEMENT_CLASS; + /** `Ember.EventDispatcher` handles delegating browser events to their corresponding `Ember.Views.` For example, when you click on a view, @@ -154,13 +157,13 @@ export default EmberObject.extend({ rootElement = jQuery(get(this, 'rootElement')); - Ember.assert(`You cannot use the same root element (${rootElement.selector || rootElement[0].tagName}) multiple times in an Ember.Application`, !rootElement.is('.ember-application')); - Ember.assert('You cannot make a new Ember.Application using a root element that is a descendent of an existing Ember.Application', !rootElement.closest('.ember-application').length); - Ember.assert('You cannot make a new Ember.Application using a root element that is an ancestor of an existing Ember.Application', !rootElement.find('.ember-application').length); + Ember.assert(`You cannot use the same root element (${rootElement.selector || rootElement[0].tagName}) multiple times in an Ember.Application`, !rootElement.is(ROOT_ELEMENT_SELECTOR)); + Ember.assert('You cannot make a new Ember.Application using a root element that is a descendent of an existing Ember.Application', !rootElement.closest(ROOT_ELEMENT_SELECTOR).length); + Ember.assert('You cannot make a new Ember.Application using a root element that is an ancestor of an existing Ember.Application', !rootElement.find(ROOT_ELEMENT_SELECTOR).length); - rootElement.addClass('ember-application'); + rootElement.addClass(ROOT_ELEMENT_CLASS); - Ember.assert('Unable to add "ember-application" class to rootElement. Make sure you set rootElement to the body or an element in the body.', rootElement.is('.ember-application')); + Ember.assert(`Unable to add '${ROOT_ELEMENT_CLASS}' class to rootElement. Make sure you set rootElement to the body or an element in the body.`, rootElement.is(ROOT_ELEMENT_SELECTOR)); for (event in events) { if (events.hasOwnProperty(event)) { @@ -261,7 +264,7 @@ export default EmberObject.extend({ destroy() { var rootElement = get(this, 'rootElement'); - jQuery(rootElement).off('.ember', '**').removeClass('ember-application'); + jQuery(rootElement).off('.ember', '**').removeClass(ROOT_ELEMENT_CLASS); return this._super(...arguments); },
false
Other
emberjs
ember.js
998eaa68defd4ec62ad4f371026a4bbe55145ac5.json
Remove leftover {{debugger}}
packages/ember-htmlbars/tests/integration/component_lifecycle_test.js
@@ -365,7 +365,7 @@ styles.forEach(style => { QUnit.test('changing a component\'s displayed properties inside didInsertElement() is deprecated', function(assert) { let component = style.class.extend({ - layout: compile('<div>{{debugger}}{{handle}}</div>'), + layout: compile('<div>{{handle}}</div>'), handle: '@wycats', container: container,
false
Other
emberjs
ember.js
24c6a1ec09c34a6ecfea4aee18ebd805961bdc4a.json
Add missing semicolon
STYLEGUIDE.md
@@ -376,15 +376,14 @@ var [ var person = { firstName: 'Stefan', lastName: 'Penner' -} +}; var { firstName, lastName } = person; ``` - ## Comments + Use [YUIDoc](http://yui.github.io/yuidoc/syntax/index.html) comments for
false