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 | f75b2e11955e0eb84af08039d90cdf1203465494.json | Unify component creation
Previously, we had in place three different methods for inserting views
or components into the render hierarchy. Top-level views went through
a legacy path that used RenderBuffer. Outlet’s went through our
abandoned ShadowRoot abstraction. The `{{view}}` helper and non-top-
level components went through ComponentNode.
While this commit started as an attempt to implement `{{link-to}}`, it
ended up being an exercise in unifying the above paths to just use
ComponentNode, which is itself simplified in this commit.
In order to support LinkView, we also implemented the view’s
`classNameBindings` syntax. In our approach, we dynamically translate
the `classNameBindings` microsyntax into the HTMLBars statements, then
use those to build a template that represents the view’s wrapping
element at runtime.
Once we had the class name bindings working, we were able to rewrite
the path for top-level views to use ComponentNodes. This allowed us to
remove large amounts of legacy view code, and there is almost assuredly
more code that we can now audit and remove entirely.
* Added registerKeyword facility
* Implemented classNameBindings
* Added `link` hook to keywords
* Rewrote `{{outlet}}` to use ComponentNode
* Added utility for building component templates (with nested blocks)
* Changed hook invocation order (`willRender` comes after
`willReceiveAttrs`)
* Top-level views now render through ComponentNode rather than legacy
RenderBuffer code path.
* Added zipHash stream utility
* Implemented largely working `LinkView`/`{{link-to}}` | packages/ember-htmlbars/lib/system/render-view.js | @@ -1,6 +1,7 @@
import Ember from "ember-metal/core";
import defaultEnv from "ember-htmlbars/env";
import { get } from "ember-metal/property_get";
+import ComponentNode from "ember-htmlbars/system/component-node";
export default function renderView(view, buffer, template) {
if (!template) {
@@ -9,13 +10,8 @@ export default function renderView(view, buffer, template) {
var output;
- if (template.isHTMLBars) {
- Ember.assert('template must be an object. Did you mean to call Ember.Handlebars.compile("...") or specify templateName instead?', typeof template === 'object');
- output = renderHTMLBarsTemplate(view, buffer, template);
- } else {
- Ember.assert('template must be a function. Did you mean to call Ember.Handlebars.compile("...") or specify templateName instead?', typeof template === 'function');
- output = renderLegacyTemplate(view, buffer, template);
- }
+ Ember.assert('template must be a function. Did you mean to call Ember.Handlebars.compile("...") or specify templateName instead?', typeof template === 'function');
+ output = renderLegacyTemplate(view, buffer, template);
if (output !== undefined) {
buffer.push(output);
@@ -24,17 +20,9 @@ export default function renderView(view, buffer, template) {
// This function only gets called once per render of a "root view" (`appendTo`). Otherwise,
// HTMLBars propagates the existing env and renders templates for a given render node.
-export function renderHTMLBarsTemplate(view, contextualElement, template, morph) {
- Ember.assert(
- 'The template being rendered by `' + view + '` was compiled with `' + template.revision +
- '` which does not match `Ember@VERSION_STRING_PLACEHOLDER` (this revision).',
- template.revision === 'Ember@VERSION_STRING_PLACEHOLDER'
- );
-
- var lifecycleHooks = [{ type: 'didInsertElement', view: view }];
-
+export function renderHTMLBarsBlock(view, block, renderNode) {
var env = {
- lifecycleHooks: lifecycleHooks,
+ lifecycleHooks: [],
view: view,
outletState: view.outletState,
container: view.container,
@@ -47,7 +35,9 @@ export function renderHTMLBarsTemplate(view, contextualElement, template, morph)
view.env = env;
- return template.render(view, view.env, { contextualElement: contextualElement, renderNode: morph });
+ var componentNode = new ComponentNode(view, null, renderNode, block, true);
+
+ componentNode.render(env, {});
}
function renderLegacyTemplate(view, buffer, template) { | true |
Other | emberjs | ember.js | f75b2e11955e0eb84af08039d90cdf1203465494.json | Unify component creation
Previously, we had in place three different methods for inserting views
or components into the render hierarchy. Top-level views went through
a legacy path that used RenderBuffer. Outlet’s went through our
abandoned ShadowRoot abstraction. The `{{view}}` helper and non-top-
level components went through ComponentNode.
While this commit started as an attempt to implement `{{link-to}}`, it
ended up being an exercise in unifying the above paths to just use
ComponentNode, which is itself simplified in this commit.
In order to support LinkView, we also implemented the view’s
`classNameBindings` syntax. In our approach, we dynamically translate
the `classNameBindings` microsyntax into the HTMLBars statements, then
use those to build a template that represents the view’s wrapping
element at runtime.
Once we had the class name bindings working, we were able to rewrite
the path for top-level views to use ComponentNodes. This allowed us to
remove large amounts of legacy view code, and there is almost assuredly
more code that we can now audit and remove entirely.
* Added registerKeyword facility
* Implemented classNameBindings
* Added `link` hook to keywords
* Rewrote `{{outlet}}` to use ComponentNode
* Added utility for building component templates (with nested blocks)
* Changed hook invocation order (`willRender` comes after
`willReceiveAttrs`)
* Top-level views now render through ComponentNode rather than legacy
RenderBuffer code path.
* Added zipHash stream utility
* Implemented largely working `LinkView`/`{{link-to}}` | packages/ember-htmlbars/lib/templates/link-to.hbs | @@ -1 +1 @@
-<a class="ember-view {{classes}}" href={{href}}>{{yield}}</a>
+{{#if linkTitle}}{{#if attrs.escaped}}{{linkTitle}}{{else}}{{{linkTitle}}}{{/if}}{{else}}{{yield}}{{/if}}
\ No newline at end of file | true |
Other | emberjs | ember.js | f75b2e11955e0eb84af08039d90cdf1203465494.json | Unify component creation
Previously, we had in place three different methods for inserting views
or components into the render hierarchy. Top-level views went through
a legacy path that used RenderBuffer. Outlet’s went through our
abandoned ShadowRoot abstraction. The `{{view}}` helper and non-top-
level components went through ComponentNode.
While this commit started as an attempt to implement `{{link-to}}`, it
ended up being an exercise in unifying the above paths to just use
ComponentNode, which is itself simplified in this commit.
In order to support LinkView, we also implemented the view’s
`classNameBindings` syntax. In our approach, we dynamically translate
the `classNameBindings` microsyntax into the HTMLBars statements, then
use those to build a template that represents the view’s wrapping
element at runtime.
Once we had the class name bindings working, we were able to rewrite
the path for top-level views to use ComponentNodes. This allowed us to
remove large amounts of legacy view code, and there is almost assuredly
more code that we can now audit and remove entirely.
* Added registerKeyword facility
* Implemented classNameBindings
* Added `link` hook to keywords
* Rewrote `{{outlet}}` to use ComponentNode
* Added utility for building component templates (with nested blocks)
* Changed hook invocation order (`willRender` comes after
`willReceiveAttrs`)
* Top-level views now render through ComponentNode rather than legacy
RenderBuffer code path.
* Added zipHash stream utility
* Implemented largely working `LinkView`/`{{link-to}}` | packages/ember-htmlbars/tests/integration/component_lifecycle_test.js | @@ -117,10 +117,12 @@ QUnit.test('lifecycle hooks are invoked in a predictable order', function() {
deepEqual(hooks, [
hook('middle', 'willUpdate'), hook('middle', 'willRender'),
- hook('bottom', 'willUpdate'), hook('bottom', 'willRender'),
+ hook('bottom', 'willUpdate'),
hook('bottom', 'willReceiveAttrs', { website: "tomdale.net" }),
+ hook('bottom', 'willRender'),
+
hook('bottom', 'didUpdate'), hook('bottom', 'didRender'),
hook('middle', 'didUpdate'), hook('middle', 'didRender')
]);
@@ -134,11 +136,13 @@ QUnit.test('lifecycle hooks are invoked in a predictable order', function() {
deepEqual(hooks, [
hook('top', 'willUpdate'), hook('top', 'willRender'),
- hook('middle', 'willUpdate'), hook('middle', 'willRender'),
+ hook('middle', 'willUpdate'),
hook('middle', 'willReceiveAttrs', { name: "Tom Dale" }),
+ hook('middle', 'willRender'),
- hook('bottom', 'willUpdate'), hook('bottom', 'willRender'),
+ hook('bottom', 'willUpdate'),
hook('bottom', 'willReceiveAttrs', { website: "tomdale.net" }),
+ hook('bottom', 'willRender'),
hook('bottom', 'didUpdate'), hook('bottom', 'didRender'),
hook('middle', 'didUpdate'), hook('middle', 'didRender'),
@@ -158,8 +162,9 @@ QUnit.test('lifecycle hooks are invoked in a predictable order', function() {
// in lifecycle hooks being invoked for the child.
deepEqual(hooks, [
- hook('top', 'willUpdate'), hook('top', 'willRender'),
+ hook('top', 'willUpdate'),
hook('top', 'willReceiveAttrs', { twitter: "@hipstertomdale" }),
+ hook('top', 'willRender'),
hook('top', 'didUpdate'), hook('top', 'didRender')
]);
});
@@ -234,14 +239,17 @@ QUnit.test('passing values through attrs causes lifecycle hooks to fire if the a
// the lifecycle hooks are invoked for all components.
deepEqual(hooks, [
- hook('top', 'willUpdate'), hook('top', 'willRender'),
+ hook('top', 'willUpdate'),
hook('top', 'willReceiveAttrs', { twitter: "@hipstertomdale" }),
+ hook('top', 'willRender'),
- hook('middle', 'willUpdate'), hook('middle', 'willRender'),
+ hook('middle', 'willUpdate'),
hook('middle', 'willReceiveAttrs', { twitterTop: "@hipstertomdale" }),
+ hook('middle', 'willRender'),
- hook('bottom', 'willUpdate'), hook('bottom', 'willRender'),
+ hook('bottom', 'willUpdate'),
hook('bottom', 'willReceiveAttrs', { twitterMiddle: "@hipstertomdale" }),
+ hook('bottom', 'willRender'),
hook('bottom', 'didUpdate'), hook('bottom', 'didRender'),
hook('middle', 'didUpdate'), hook('middle', 'didRender'),
@@ -320,14 +328,17 @@ QUnit.test('manually re-rendering in `willReceiveAttrs` triggers lifecycle hooks
// rerender, lifecycle hooks are invoked on all child components.
deepEqual(hooks, [
- hook('top', 'willUpdate'), hook('top', 'willRender'),
+ hook('top', 'willUpdate'),
hook('top', 'willReceiveAttrs', { twitter: "@hipstertomdale" }),
+ hook('top', 'willRender'),
- hook('middle', 'willUpdate'), hook('middle', 'willRender'),
+ hook('middle', 'willUpdate'),
hook('middle', 'willReceiveAttrs', { name: "Tom Dale" }),
+ hook('middle', 'willRender'),
- hook('bottom', 'willUpdate'), hook('bottom', 'willRender'),
+ hook('bottom', 'willUpdate'),
hook('bottom', 'willReceiveAttrs', { website: "tomdale.net" }),
+ hook('bottom', 'willRender'),
hook('bottom', 'didUpdate'), hook('bottom', 'didRender'),
hook('middle', 'didUpdate'), hook('middle', 'didRender'), | true |
Other | emberjs | ember.js | f75b2e11955e0eb84af08039d90cdf1203465494.json | Unify component creation
Previously, we had in place three different methods for inserting views
or components into the render hierarchy. Top-level views went through
a legacy path that used RenderBuffer. Outlet’s went through our
abandoned ShadowRoot abstraction. The `{{view}}` helper and non-top-
level components went through ComponentNode.
While this commit started as an attempt to implement `{{link-to}}`, it
ended up being an exercise in unifying the above paths to just use
ComponentNode, which is itself simplified in this commit.
In order to support LinkView, we also implemented the view’s
`classNameBindings` syntax. In our approach, we dynamically translate
the `classNameBindings` microsyntax into the HTMLBars statements, then
use those to build a template that represents the view’s wrapping
element at runtime.
Once we had the class name bindings working, we were able to rewrite
the path for top-level views to use ComponentNodes. This allowed us to
remove large amounts of legacy view code, and there is almost assuredly
more code that we can now audit and remove entirely.
* Added registerKeyword facility
* Implemented classNameBindings
* Added `link` hook to keywords
* Rewrote `{{outlet}}` to use ComponentNode
* Added utility for building component templates (with nested blocks)
* Changed hook invocation order (`willRender` comes after
`willReceiveAttrs`)
* Top-level views now render through ComponentNode rather than legacy
RenderBuffer code path.
* Added zipHash stream utility
* Implemented largely working `LinkView`/`{{link-to}}` | packages/ember-metal-views/lib/renderer.js | @@ -1,13 +1,13 @@
import DOMHelper from "dom-helper";
import environment from "ember-metal/environment";
-import RenderBuffer from "ember-views/system/render_buffer";
import run from "ember-metal/run_loop";
import { get } from "ember-metal/property_get";
import { set } from "ember-metal/property_set";
import {
_instrumentStart,
subscribers
} from "ember-metal/instrumentation";
+import buildComponentTemplate from "ember-views/system/build-component-template";
var domHelper = environment.hasDOM ? new DOMHelper() : null;
@@ -16,27 +16,27 @@ function Renderer(_helper, _destinedForDOM) {
}
Renderer.prototype.renderTopLevelView =
- function Renderer_renderTopLevelView(view, morph) {
- view.ownerView = morph.state.view = view;
- view.renderNode = morph;
-
- var contentMorph = this.contentMorphForView(view, morph);
+ function Renderer_renderTopLevelView(view, renderNode) {
+ view.ownerView = renderNode.state.view = view;
+ view.renderNode = renderNode;
var template = get(view, 'layout') || get(view, 'template');
+ var componentInfo = { component: view };
- if (template) {
- var result = view.renderTemplate(view, contentMorph.contextualElement, template, contentMorph);
+ var block = buildComponentTemplate(componentInfo, {}, {
+ self: view,
+ template: template.raw
+ }).block;
- view.lastResult = morph.lastResult = result;
- window.lastMorph = morph;
+ view.renderBlock(block, renderNode);
+ view.lastResult = renderNode.lastResult;
- this.dispatchLifecycleHooks(view.env);
- }
+ this.dispatchLifecycleHooks(view.env);
};
Renderer.prototype.revalidateTopLevelView =
function Renderer_revalidateTopLevelView(view) {
- view.renderNode.lastResult.revalidate();
+ view.renderNode.lastResult.revalidate(view.env);
this.dispatchLifecycleHooks(view.env);
};
@@ -67,12 +67,6 @@ Renderer.prototype.appendTo =
run.scheduleOnce('render', this, this.renderTopLevelView, view, morph);
};
-// This entry point is called by the `#view` keyword in templates
-Renderer.prototype.contentMorphForView =
- function Renderer_contentMorphForView(view, morph, options) {
- return contentMorphForView(view, morph, this._dom, options);
- };
-
Renderer.prototype.willCreateElement = function (view) {
if (subscribers.length && view.instrumentDetails) {
view._instrumentEnd = _instrumentStart('render.'+view.instrumentName, function viewInstrumentDetails() {
@@ -163,60 +157,3 @@ Renderer.prototype.didDestroyElement = function (view) {
}; // element destroyed so view.destroy shouldn't try to remove it removedFromDOM
export default Renderer;
-
-function contentMorphForView(view, morph, dom, options) {
- var buffer = new RenderBuffer(dom);
- var contextualElement = morph.contextualElement;
- var contentMorph;
-
- if (options && options.class) {
- view.classNames.push(options.class);
- }
-
- if (options && options.id) {
- view.elementId = options.id;
- }
-
- view.renderer.willCreateElement(view);
-
- var tagName = view.tagName;
-
- if (tagName !== null && typeof tagName === 'object' && tagName.isDescriptor) {
- tagName = get(view, 'tagName');
- Ember.deprecate('In the future using a computed property to define tagName will not be permitted. That value will be respected, but changing it will not update the element.', !tagName);
- }
-
- var classNameBindings = view.classNameBindings;
- var taglessViewWithClassBindings = tagName === '' && (classNameBindings && classNameBindings.length > 0);
-
- if (tagName === null || tagName === undefined) {
- tagName = 'div';
- }
-
- Ember.assert('You cannot use `classNameBindings` on a tag-less view: ' + view.toString(), !taglessViewWithClassBindings);
-
- buffer.reset(tagName, contextualElement);
-
- var element;
-
- if (tagName !== '') {
- if (view.applyAttributesToBuffer) {
- view.applyAttributesToBuffer(buffer);
- }
- element = buffer.generateElement();
- }
-
- if (element && element.nodeType === 1) {
- view.element = element;
- contentMorph = dom.insertMorphBefore(element, null);
- contentMorph.ownerNode = morph.ownerNode;
- morph.childNodes = [contentMorph];
- morph.setContent(element);
- } else {
- contentMorph = morph;
- }
-
- view.renderer.didCreateElement(view);
-
- return contentMorph;
-} | true |
Other | emberjs | ember.js | f75b2e11955e0eb84af08039d90cdf1203465494.json | Unify component creation
Previously, we had in place three different methods for inserting views
or components into the render hierarchy. Top-level views went through
a legacy path that used RenderBuffer. Outlet’s went through our
abandoned ShadowRoot abstraction. The `{{view}}` helper and non-top-
level components went through ComponentNode.
While this commit started as an attempt to implement `{{link-to}}`, it
ended up being an exercise in unifying the above paths to just use
ComponentNode, which is itself simplified in this commit.
In order to support LinkView, we also implemented the view’s
`classNameBindings` syntax. In our approach, we dynamically translate
the `classNameBindings` microsyntax into the HTMLBars statements, then
use those to build a template that represents the view’s wrapping
element at runtime.
Once we had the class name bindings working, we were able to rewrite
the path for top-level views to use ComponentNodes. This allowed us to
remove large amounts of legacy view code, and there is almost assuredly
more code that we can now audit and remove entirely.
* Added registerKeyword facility
* Implemented classNameBindings
* Added `link` hook to keywords
* Rewrote `{{outlet}}` to use ComponentNode
* Added utility for building component templates (with nested blocks)
* Changed hook invocation order (`willRender` comes after
`willReceiveAttrs`)
* Top-level views now render through ComponentNode rather than legacy
RenderBuffer code path.
* Added zipHash stream utility
* Implemented largely working `LinkView`/`{{link-to}}` | packages/ember-metal/lib/streams/utils.js | @@ -200,14 +200,16 @@ export function or(first, second) {
}
export function addDependency(stream, dependency) {
- if (dependency) {
+ Ember.assert("Cannot add a stream as a dependency to a non-stream", isStream(stream) || !isStream(dependency));
+ if (isStream(stream)) {
stream.addDependency(dependency);
}
}
export function zip(streams, callback) {
var stream = new Stream(function() {
- return callback(readArray(streams));
+ var array = readArray(streams);
+ return callback ? callback(array) : array;
});
for (var i=0, l=streams.length; i<l; i++) {
@@ -217,6 +219,19 @@ export function zip(streams, callback) {
return stream;
}
+export function zipHash(object, callback) {
+ var stream = new Stream(function() {
+ var hash = readHash(object);
+ return callback ? callback(hash) : hash;
+ });
+
+ for (var prop in object) {
+ stream.addDependency(object[prop]);
+ }
+
+ return stream;
+}
+
/**
Generate a new stream by providing a source stream and a function that can
be used to transform the stream's value. In the case of a non-stream object, | true |
Other | emberjs | ember.js | f75b2e11955e0eb84af08039d90cdf1203465494.json | Unify component creation
Previously, we had in place three different methods for inserting views
or components into the render hierarchy. Top-level views went through
a legacy path that used RenderBuffer. Outlet’s went through our
abandoned ShadowRoot abstraction. The `{{view}}` helper and non-top-
level components went through ComponentNode.
While this commit started as an attempt to implement `{{link-to}}`, it
ended up being an exercise in unifying the above paths to just use
ComponentNode, which is itself simplified in this commit.
In order to support LinkView, we also implemented the view’s
`classNameBindings` syntax. In our approach, we dynamically translate
the `classNameBindings` microsyntax into the HTMLBars statements, then
use those to build a template that represents the view’s wrapping
element at runtime.
Once we had the class name bindings working, we were able to rewrite
the path for top-level views to use ComponentNodes. This allowed us to
remove large amounts of legacy view code, and there is almost assuredly
more code that we can now audit and remove entirely.
* Added registerKeyword facility
* Implemented classNameBindings
* Added `link` hook to keywords
* Rewrote `{{outlet}}` to use ComponentNode
* Added utility for building component templates (with nested blocks)
* Changed hook invocation order (`willRender` comes after
`willReceiveAttrs`)
* Top-level views now render through ComponentNode rather than legacy
RenderBuffer code path.
* Added zipHash stream utility
* Implemented largely working `LinkView`/`{{link-to}}` | packages/ember-metal/tests/streams/key-stream-test.js | @@ -86,7 +86,7 @@ QUnit.test("is notified when setSource is called with a new stream whose value i
nameStream.value(); // Prime the stream to notify subscribers
nameStream.setSource(new Stream(function() {
- return { name: "wycats" };
+ return { name: "wycats" };
}));
equal(count, 1, "Subscribers called correct number of times");
@@ -101,7 +101,7 @@ QUnit.test("is notified when setSource is called with a new stream whose value i
nameStream.value(); // Prime the stream to notify subscribers
nameStream.setSource(new Stream(function() {
- return object;
+ return object;
}));
equal(count, 1, "Subscribers called correct number of times"); | true |
Other | emberjs | ember.js | f75b2e11955e0eb84af08039d90cdf1203465494.json | Unify component creation
Previously, we had in place three different methods for inserting views
or components into the render hierarchy. Top-level views went through
a legacy path that used RenderBuffer. Outlet’s went through our
abandoned ShadowRoot abstraction. The `{{view}}` helper and non-top-
level components went through ComponentNode.
While this commit started as an attempt to implement `{{link-to}}`, it
ended up being an exercise in unifying the above paths to just use
ComponentNode, which is itself simplified in this commit.
In order to support LinkView, we also implemented the view’s
`classNameBindings` syntax. In our approach, we dynamically translate
the `classNameBindings` microsyntax into the HTMLBars statements, then
use those to build a template that represents the view’s wrapping
element at runtime.
Once we had the class name bindings working, we were able to rewrite
the path for top-level views to use ComponentNodes. This allowed us to
remove large amounts of legacy view code, and there is almost assuredly
more code that we can now audit and remove entirely.
* Added registerKeyword facility
* Implemented classNameBindings
* Added `link` hook to keywords
* Rewrote `{{outlet}}` to use ComponentNode
* Added utility for building component templates (with nested blocks)
* Changed hook invocation order (`willRender` comes after
`willReceiveAttrs`)
* Top-level views now render through ComponentNode rather than legacy
RenderBuffer code path.
* Added zipHash stream utility
* Implemented largely working `LinkView`/`{{link-to}}` | packages/ember-routing-htmlbars/lib/keywords/link-to.js | @@ -0,0 +1,30 @@
+import { readArray, readHash } from "ember-metal/streams/utils";
+//import ControllerMixin from "ember-runtime/mixins/controller";
+import Ember from "ember-metal/core"; // assert
+import merge from "ember-metal/merge";
+
+export default {
+ link: function(state, params, hash) {
+ Ember.assert("You must provide one or more parameters to the link-to helper.", params.length);
+ },
+
+ render: function(morph, env, scope, params, hash, template, inverse, visitor) {
+ var attrs = merge({}, readHash(hash));
+ attrs.params = readArray(params);
+
+ // Used for deprecations (to tell the user what view the deprecated syntax
+ // was used in).
+ attrs.view = env.view;
+
+ // TODO: Remove once `hasBlock` is working again
+ attrs.hasBlock = !!template;
+
+ attrs.escaped = !morph.parseTextAsHTML;
+
+ env.hooks.component(morph, env, scope, '-link-to', attrs, template, visitor);
+ },
+
+ rerender: function(morph, env, scope, params, hash, template, inverse, visitor) {
+ this.render(morph, env, scope, params, hash, template, inverse, visitor);
+ }
+}; | true |
Other | emberjs | ember.js | f75b2e11955e0eb84af08039d90cdf1203465494.json | Unify component creation
Previously, we had in place three different methods for inserting views
or components into the render hierarchy. Top-level views went through
a legacy path that used RenderBuffer. Outlet’s went through our
abandoned ShadowRoot abstraction. The `{{view}}` helper and non-top-
level components went through ComponentNode.
While this commit started as an attempt to implement `{{link-to}}`, it
ended up being an exercise in unifying the above paths to just use
ComponentNode, which is itself simplified in this commit.
In order to support LinkView, we also implemented the view’s
`classNameBindings` syntax. In our approach, we dynamically translate
the `classNameBindings` microsyntax into the HTMLBars statements, then
use those to build a template that represents the view’s wrapping
element at runtime.
Once we had the class name bindings working, we were able to rewrite
the path for top-level views to use ComponentNodes. This allowed us to
remove large amounts of legacy view code, and there is almost assuredly
more code that we can now audit and remove entirely.
* Added registerKeyword facility
* Implemented classNameBindings
* Added `link` hook to keywords
* Rewrote `{{outlet}}` to use ComponentNode
* Added utility for building component templates (with nested blocks)
* Changed hook invocation order (`willRender` comes after
`willReceiveAttrs`)
* Top-level views now render through ComponentNode rather than legacy
RenderBuffer code path.
* Added zipHash stream utility
* Implemented largely working `LinkView`/`{{link-to}}` | packages/ember-routing-htmlbars/lib/main.js | @@ -9,19 +9,18 @@ Ember Routing HTMLBars Helpers
import Ember from "ember-metal/core";
import { registerHelper } from "ember-htmlbars/helpers";
+import { registerKeyword } from "ember-htmlbars/keywords";
import { renderHelper } from "ember-routing-htmlbars/helpers/render";
-import {
- linkToHelper,
- deprecatedLinkToHelper
-} from "ember-routing-htmlbars/helpers/link-to";
+import linkTo from "ember-routing-htmlbars/keywords/link-to";
import { actionHelper } from "ember-routing-htmlbars/helpers/action";
import { queryParamsHelper } from "ember-routing-htmlbars/helpers/query-params";
registerHelper('render', renderHelper);
-registerHelper('link-to', linkToHelper);
-registerHelper('linkTo', deprecatedLinkToHelper);
registerHelper('action', actionHelper);
registerHelper('query-params', queryParamsHelper);
+registerKeyword('link-to', linkTo);
+registerKeyword('linkTo', linkTo);
+
export default Ember; | true |
Other | emberjs | ember.js | f75b2e11955e0eb84af08039d90cdf1203465494.json | Unify component creation
Previously, we had in place three different methods for inserting views
or components into the render hierarchy. Top-level views went through
a legacy path that used RenderBuffer. Outlet’s went through our
abandoned ShadowRoot abstraction. The `{{view}}` helper and non-top-
level components went through ComponentNode.
While this commit started as an attempt to implement `{{link-to}}`, it
ended up being an exercise in unifying the above paths to just use
ComponentNode, which is itself simplified in this commit.
In order to support LinkView, we also implemented the view’s
`classNameBindings` syntax. In our approach, we dynamically translate
the `classNameBindings` microsyntax into the HTMLBars statements, then
use those to build a template that represents the view’s wrapping
element at runtime.
Once we had the class name bindings working, we were able to rewrite
the path for top-level views to use ComponentNodes. This allowed us to
remove large amounts of legacy view code, and there is almost assuredly
more code that we can now audit and remove entirely.
* Added registerKeyword facility
* Implemented classNameBindings
* Added `link` hook to keywords
* Rewrote `{{outlet}}` to use ComponentNode
* Added utility for building component templates (with nested blocks)
* Changed hook invocation order (`willRender` comes after
`willReceiveAttrs`)
* Top-level views now render through ComponentNode rather than legacy
RenderBuffer code path.
* Added zipHash stream utility
* Implemented largely working `LinkView`/`{{link-to}}` | packages/ember-routing-htmlbars/tests/helpers/link-to_test.js | @@ -7,6 +7,8 @@ import Controller from "ember-runtime/controllers/controller";
import { Registry } from "ember-runtime/system/container";
import { runAppend, runDestroy } from "ember-runtime/tests/utils";
import EmberObject from "ember-runtime/system/object";
+import ComponentLookup from "ember-views/component_lookup";
+import LinkView from "ember-routing-views/views/link";
var view;
var container;
@@ -25,6 +27,9 @@ registry.register('service:-routing', EmberObject.extend({
generateURL: function() { return "/"; }
}));
+registry.register('component-lookup:main', ComponentLookup);
+registry.register('component:-link-to', LinkView);
+
QUnit.module("ember-routing-htmlbars: link-to helper", {
setup() {
container = registry.container(); | true |
Other | emberjs | ember.js | f75b2e11955e0eb84af08039d90cdf1203465494.json | Unify component creation
Previously, we had in place three different methods for inserting views
or components into the render hierarchy. Top-level views went through
a legacy path that used RenderBuffer. Outlet’s went through our
abandoned ShadowRoot abstraction. The `{{view}}` helper and non-top-
level components went through ComponentNode.
While this commit started as an attempt to implement `{{link-to}}`, it
ended up being an exercise in unifying the above paths to just use
ComponentNode, which is itself simplified in this commit.
In order to support LinkView, we also implemented the view’s
`classNameBindings` syntax. In our approach, we dynamically translate
the `classNameBindings` microsyntax into the HTMLBars statements, then
use those to build a template that represents the view’s wrapping
element at runtime.
Once we had the class name bindings working, we were able to rewrite
the path for top-level views to use ComponentNodes. This allowed us to
remove large amounts of legacy view code, and there is almost assuredly
more code that we can now audit and remove entirely.
* Added registerKeyword facility
* Implemented classNameBindings
* Added `link` hook to keywords
* Rewrote `{{outlet}}` to use ComponentNode
* Added utility for building component templates (with nested blocks)
* Changed hook invocation order (`willRender` comes after
`willReceiveAttrs`)
* Top-level views now render through ComponentNode rather than legacy
RenderBuffer code path.
* Added zipHash stream utility
* Implemented largely working `LinkView`/`{{link-to}}` | packages/ember-routing-views/lib/initializers/link-to-component.js | @@ -0,0 +1,12 @@
+import { onLoad } from "ember-runtime/system/lazy_load";
+import linkToComponent from "ember-routing-views/views/link";
+
+onLoad('Ember.Application', function(Application) {
+ Application.initializer({
+ name: 'link-to-component',
+ initialize: function(registry) {
+ registry.register('component:-link-to', linkToComponent);
+ }
+ });
+});
+ | true |
Other | emberjs | ember.js | f75b2e11955e0eb84af08039d90cdf1203465494.json | Unify component creation
Previously, we had in place three different methods for inserting views
or components into the render hierarchy. Top-level views went through
a legacy path that used RenderBuffer. Outlet’s went through our
abandoned ShadowRoot abstraction. The `{{view}}` helper and non-top-
level components went through ComponentNode.
While this commit started as an attempt to implement `{{link-to}}`, it
ended up being an exercise in unifying the above paths to just use
ComponentNode, which is itself simplified in this commit.
In order to support LinkView, we also implemented the view’s
`classNameBindings` syntax. In our approach, we dynamically translate
the `classNameBindings` microsyntax into the HTMLBars statements, then
use those to build a template that represents the view’s wrapping
element at runtime.
Once we had the class name bindings working, we were able to rewrite
the path for top-level views to use ComponentNodes. This allowed us to
remove large amounts of legacy view code, and there is almost assuredly
more code that we can now audit and remove entirely.
* Added registerKeyword facility
* Implemented classNameBindings
* Added `link` hook to keywords
* Rewrote `{{outlet}}` to use ComponentNode
* Added utility for building component templates (with nested blocks)
* Changed hook invocation order (`willRender` comes after
`willReceiveAttrs`)
* Top-level views now render through ComponentNode rather than legacy
RenderBuffer code path.
* Added zipHash stream utility
* Implemented largely working `LinkView`/`{{link-to}}` | packages/ember-routing-views/lib/main.js | @@ -7,6 +7,7 @@ Ember Routing Views
*/
import Ember from "ember-metal/core";
+import "ember-routing-views/initializers/link-to-component";
import { LinkView } from "ember-routing-views/views/link";
import { | true |
Other | emberjs | ember.js | f75b2e11955e0eb84af08039d90cdf1203465494.json | Unify component creation
Previously, we had in place three different methods for inserting views
or components into the render hierarchy. Top-level views went through
a legacy path that used RenderBuffer. Outlet’s went through our
abandoned ShadowRoot abstraction. The `{{view}}` helper and non-top-
level components went through ComponentNode.
While this commit started as an attempt to implement `{{link-to}}`, it
ended up being an exercise in unifying the above paths to just use
ComponentNode, which is itself simplified in this commit.
In order to support LinkView, we also implemented the view’s
`classNameBindings` syntax. In our approach, we dynamically translate
the `classNameBindings` microsyntax into the HTMLBars statements, then
use those to build a template that represents the view’s wrapping
element at runtime.
Once we had the class name bindings working, we were able to rewrite
the path for top-level views to use ComponentNodes. This allowed us to
remove large amounts of legacy view code, and there is almost assuredly
more code that we can now audit and remove entirely.
* Added registerKeyword facility
* Implemented classNameBindings
* Added `link` hook to keywords
* Rewrote `{{outlet}}` to use ComponentNode
* Added utility for building component templates (with nested blocks)
* Changed hook invocation order (`willRender` comes after
`willReceiveAttrs`)
* Top-level views now render through ComponentNode rather than legacy
RenderBuffer code path.
* Added zipHash stream utility
* Implemented largely working `LinkView`/`{{link-to}}` | packages/ember-routing-views/lib/views/link.js | @@ -7,11 +7,13 @@ import Ember from "ember-metal/core"; // FEATURES, Logger, assert
import { get } from "ember-metal/property_get";
import { computed } from "ember-metal/computed";
-import { fmt } from "ember-runtime/system/string";
import { isSimpleClick } from "ember-views/system/utils";
import EmberComponent from "ember-views/views/component";
-import { read, subscribe } from "ember-metal/streams/utils";
import inject from "ember-runtime/inject";
+import ControllerMixin from "ember-runtime/mixins/controller";
+
+import linkToTemplate from "ember-htmlbars/templates/link-to";
+linkToTemplate.revision = 'Ember@VERSION_STRING_PLACEHOLDER';
var linkViewClassNameBindings = ['active', 'loading', 'disabled'];
if (Ember.FEATURES.isEnabled('ember-routing-transitioning-classes')) {
@@ -32,7 +34,9 @@ if (Ember.FEATURES.isEnabled('ember-routing-transitioning-classes')) {
@extends Ember.View
@see {Handlebars.helpers.link-to}
**/
-var LinkView = EmberComponent.extend({
+var LinkComponent = EmberComponent.extend({
+ defaultLayout: linkToTemplate,
+
tagName: 'a',
/**
@@ -129,7 +133,7 @@ var LinkView = EmberComponent.extend({
@property attributeBindings
@type Array | String
- @default ['href', 'title', 'rel', 'tabindex', 'target']
+ @default ['title', 'rel', 'tabindex', 'target']
**/
attributeBindings: ['href', 'title', 'rel', 'tabindex', 'target'],
@@ -204,53 +208,6 @@ var LinkView = EmberComponent.extend({
_routing: inject.service('-routing'),
/**
- This method is invoked by observers installed during `init` that fire
- whenever the params change
-
- @private
- @method _paramsChanged
- @since 1.3.0
- */
- _paramsChanged() {
- this.notifyPropertyChange('resolvedParams');
- },
-
- /**
- This is called to setup observers that will trigger a rerender.
-
- @private
- @method _setupPathObservers
- @since 1.3.0
- **/
- _setupPathObservers() {
- var params = this.params;
-
- var scheduledParamsChanged = this._wrapAsScheduled(this._paramsChanged);
-
- for (var i = 0; i < params.length; i++) {
- subscribe(params[i], scheduledParamsChanged, this);
- }
-
- var queryParamsObject = this.queryParamsObject;
- if (queryParamsObject) {
- var values = queryParamsObject.values;
- for (var k in values) {
- if (!values.hasOwnProperty(k)) {
- continue;
- }
-
- subscribe(values[k], scheduledParamsChanged, this);
- }
- }
- },
-
- afterRender() {
- this._super(...arguments);
- this._setupPathObservers();
- },
-
- /**
-
Accessed as a classname binding to apply the `LinkView`'s `disabledClass`
CSS `class` to the element when the link is disabled.
@@ -281,7 +238,7 @@ var LinkView = EmberComponent.extend({
@property active
**/
- active: computed('loadedParams', function computeLinkViewActive() {
+ active: computed('attrs.params', function computeLinkViewActive() {
var currentState = get(this, '_routing.currentState');
return computeActive(this, currentState);
}),
@@ -308,21 +265,6 @@ var LinkView = EmberComponent.extend({
return get(this, 'active') && !willBeActive && 'ember-transitioning-out';
}),
- /**
- Accessed as a classname binding to apply the `LinkView`'s `loadingClass`
- CSS `class` to the element when the link is loading.
-
- A `LinkView` is considered loading when it has at least one
- parameter whose value is currently null or undefined. During
- this time, clicking the link will perform no transition and
- emit a warning that the link is still in a loading state.
-
- @property loading
- **/
- loading: computed('loadedParams', function computeLinkViewLoading() {
- if (!get(this, 'loadedParams')) { return get(this, 'loadingClass'); }
- }),
-
/**
Event handler that invokes the link, activating the associated route.
@@ -334,7 +276,7 @@ var LinkView = EmberComponent.extend({
if (!isSimpleClick(event)) { return true; }
if (this.preventDefault !== false) {
- var targetAttribute = get(this, 'target');
+ var targetAttribute = this.attrs.target;
if (!targetAttribute || targetAttribute === '_self') {
event.preventDefault();
}
@@ -349,89 +291,15 @@ var LinkView = EmberComponent.extend({
return false;
}
- var targetAttribute2 = get(this, 'target');
+ var targetAttribute2 = this.attrs.target;
if (targetAttribute2 && targetAttribute2 !== '_self') {
return false;
}
- var params = get(this, 'loadedParams');
- get(this, '_routing').transitionTo(params.targetRouteName, params.models, params.queryParams, get(this, 'replace'));
+ get(this, '_routing').transitionTo(get(this, 'targetRouteName'), get(this, 'models'), get(this, 'queryParams'), get(this, 'attrs.replace'));
},
- /**
- Computed property that returns an array of the
- resolved parameters passed to the `link-to` helper,
- e.g.:
-
- ```hbs
- {{link-to a b '123' c}}
- ```
-
- will generate a `resolvedParams` of:
-
- ```js
- [aObject, bObject, '123', cObject]
- ```
-
- @private
- @property
- @return {Array}
- */
- resolvedParams: computed('_routing.currentState', function() {
- var params = this.params;
- var targetRouteName;
- var models = [];
- var onlyQueryParamsSupplied = (params.length === 0);
-
- if (onlyQueryParamsSupplied) {
- targetRouteName = get(this, '_routing.currentRouteName');
- } else {
- targetRouteName = read(params[0]);
-
- for (var i = 1; i < params.length; i++) {
- models.push(read(params[i]));
- }
- }
-
- var suppliedQueryParams = getResolvedQueryParams(this, targetRouteName);
-
- return {
- targetRouteName: targetRouteName,
- models: models,
- queryParams: suppliedQueryParams
- };
- }),
-
- /**
- Computed property that returns the current route name,
- dynamic segments, and query params. Returns falsy if
- for null/undefined params to indicate that the link view
- is still in a loading state.
-
- @private
- @property
- @return {Array} An array with the route name and any dynamic segments
- **/
- loadedParams: computed('resolvedParams', function computeLinkViewRouteArgs() {
- var routing = get(this, '_routing');
- if (!routing) { return; }
-
- var resolvedParams = get(this, 'resolvedParams');
- var namedRoute = resolvedParams.targetRouteName;
-
- if (!namedRoute) { return; }
-
- Ember.assert(fmt("The attempt to link-to route '%@' failed. " +
- "The router did not find '%@' in its possible routes: '%@'",
- [namedRoute, namedRoute, routing.availableRoutes().join("', '")]),
- routing.hasRoute(namedRoute));
-
- if (!paramsAreLoaded(resolvedParams.models)) { return; }
-
- return resolvedParams;
- }),
-
- queryParamsObject: null,
+ queryParams: null,
/**
Sets the element's `href` attribute to the url for
@@ -442,17 +310,11 @@ var LinkView = EmberComponent.extend({
@property href
**/
- href: computed('loadedParams', function computeLinkViewHref() {
+ href: computed('models', function computeLinkViewHref() {
if (get(this, 'tagName') !== 'a') { return; }
var routing = get(this, '_routing');
- var params = get(this, 'loadedParams');
-
- if (!params) {
- return get(this, 'loadingHref');
- }
-
- return routing.generateURL(params.targetRouteName, params.models, params.queryParams);
+ return routing.generateURL(get(this, 'targetRouteName'), get(this, 'models'), get(this, 'queryParams'));
}),
/**
@@ -463,42 +325,80 @@ var LinkView = EmberComponent.extend({
@type String
@default #
*/
- loadingHref: '#'
-});
+ loadingHref: '#',
-LinkView.toString = function() { return "LinkView"; };
+ willRender: function() {
+ var queryParams;
-function getResolvedQueryParams(linkView, targetRouteName) {
- var queryParamsObject = linkView.queryParamsObject;
- var resolvedQueryParams = {};
+ var attrs = this.attrs;
- if (!queryParamsObject) { return resolvedQueryParams; }
+ // Do not mutate params in place
+ var params = attrs.params.slice();
- var values = queryParamsObject.values;
- for (var key in values) {
- if (!values.hasOwnProperty(key)) { continue; }
- resolvedQueryParams[key] = read(values[key]);
- }
+ Ember.assert("You must provide one or more parameters to the link-to helper.", params.length);
- return resolvedQueryParams;
-}
+ var lastParam = params[params.length - 1];
-function paramsAreLoaded(params) {
- for (var i = 0, len = params.length; i < len; ++i) {
- var param = params[i];
- if (param === null || typeof param === 'undefined') {
- return false;
+ if (lastParam && lastParam.isQueryParams) {
+ queryParams = params.pop();
+ }
+ this.set('queryParams', queryParams || {});
+
+ if (attrs.disabledClass) {
+ this.set('disabledClass', attrs.disabledClass);
+ }
+
+ if (attrs.activeClass) {
+ this.set('activeClass', attrs.activeClass);
+ }
+
+ if (attrs.disabledWhen) {
+ this.set('disabled', attrs.disabledWhen);
+ }
+
+ var currentWhen = attrs['current-when'];
+
+ if (attrs.currentWhen) {
+ Ember.deprecate('Using currentWhen with {{link-to}} is deprecated in favor of `current-when`.', !attrs.currentWhen);
+ currentWhen = attrs.currentWhen;
+ }
+
+ if (currentWhen) {
+ this.set('currentWhen', currentWhen);
+ }
+
+ // TODO: Change to built-in hasBlock once it's available
+ if (!attrs.hasBlock) {
+ this.set('linkTitle', params.shift());
+ }
+
+ for (var i = 0; i < params.length; i++) {
+ var value = params[i];
+
+ while (ControllerMixin.detect(value)) {
+ Ember.deprecate('Providing `{{link-to}}` with a param that is wrapped in a controller is deprecated. Please update `' + attrs.view + '` to use `{{link-to "post" someController.model}}` instead.');
+ value = value.get('model');
+ }
+
+ params[i] = value;
}
+
+ if (params.length !== 0) {
+ this.set('targetRouteName', params.shift());
+ }
+
+ this.set('models', params);
}
- return true;
-}
+});
+
+LinkComponent.toString = function() { return "LinkComponent"; };
function computeActive(view, routerState) {
if (get(view, 'loading')) { return false; }
- var currentWhen = view['current-when'] || view.currentWhen;
+ var currentWhen = get(view, 'currentWhen');
var isCurrentWhenSpecified = !!currentWhen;
- currentWhen = currentWhen || get(view, 'loadedParams').targetRouteName;
+ currentWhen = currentWhen || get(view, 'targetRouteName');
currentWhen = currentWhen.split(' ');
for (var i = 0, len = currentWhen.length; i < len; i++) {
if (isActiveForRoute(view, currentWhen[i], isCurrentWhenSpecified, routerState)) {
@@ -510,11 +410,8 @@ function computeActive(view, routerState) {
}
function isActiveForRoute(view, routeName, isCurrentWhenSpecified, routerState) {
- var params = get(view, 'loadedParams');
var service = get(view, '_routing');
- return service.isActiveForRoute(params, routeName, routerState, isCurrentWhenSpecified);
+ return service.isActiveForRoute(get(view, 'models'), get(view, 'queryParams'), routeName, routerState, isCurrentWhenSpecified);
}
-export {
- LinkView
-};
+export default LinkComponent; | true |
Other | emberjs | ember.js | f75b2e11955e0eb84af08039d90cdf1203465494.json | Unify component creation
Previously, we had in place three different methods for inserting views
or components into the render hierarchy. Top-level views went through
a legacy path that used RenderBuffer. Outlet’s went through our
abandoned ShadowRoot abstraction. The `{{view}}` helper and non-top-
level components went through ComponentNode.
While this commit started as an attempt to implement `{{link-to}}`, it
ended up being an exercise in unifying the above paths to just use
ComponentNode, which is itself simplified in this commit.
In order to support LinkView, we also implemented the view’s
`classNameBindings` syntax. In our approach, we dynamically translate
the `classNameBindings` microsyntax into the HTMLBars statements, then
use those to build a template that represents the view’s wrapping
element at runtime.
Once we had the class name bindings working, we were able to rewrite
the path for top-level views to use ComponentNodes. This allowed us to
remove large amounts of legacy view code, and there is almost assuredly
more code that we can now audit and remove entirely.
* Added registerKeyword facility
* Implemented classNameBindings
* Added `link` hook to keywords
* Rewrote `{{outlet}}` to use ComponentNode
* Added utility for building component templates (with nested blocks)
* Changed hook invocation order (`willRender` comes after
`willReceiveAttrs`)
* Top-level views now render through ComponentNode rather than legacy
RenderBuffer code path.
* Added zipHash stream utility
* Implemented largely working `LinkView`/`{{link-to}}` | packages/ember-routing-views/lib/views/outlet.js | @@ -28,6 +28,8 @@ export var CoreOutletView = View.extend({
this.dirtyOutlets();
this._outlets = [];
+ this._outlets = [];
+
this.scheduleRevalidate();
}
}, | true |
Other | emberjs | ember.js | f75b2e11955e0eb84af08039d90cdf1203465494.json | Unify component creation
Previously, we had in place three different methods for inserting views
or components into the render hierarchy. Top-level views went through
a legacy path that used RenderBuffer. Outlet’s went through our
abandoned ShadowRoot abstraction. The `{{view}}` helper and non-top-
level components went through ComponentNode.
While this commit started as an attempt to implement `{{link-to}}`, it
ended up being an exercise in unifying the above paths to just use
ComponentNode, which is itself simplified in this commit.
In order to support LinkView, we also implemented the view’s
`classNameBindings` syntax. In our approach, we dynamically translate
the `classNameBindings` microsyntax into the HTMLBars statements, then
use those to build a template that represents the view’s wrapping
element at runtime.
Once we had the class name bindings working, we were able to rewrite
the path for top-level views to use ComponentNodes. This allowed us to
remove large amounts of legacy view code, and there is almost assuredly
more code that we can now audit and remove entirely.
* Added registerKeyword facility
* Implemented classNameBindings
* Added `link` hook to keywords
* Rewrote `{{outlet}}` to use ComponentNode
* Added utility for building component templates (with nested blocks)
* Changed hook invocation order (`willRender` comes after
`willReceiveAttrs`)
* Top-level views now render through ComponentNode rather than legacy
RenderBuffer code path.
* Added zipHash stream utility
* Implemented largely working `LinkView`/`{{link-to}}` | packages/ember-routing/lib/services/routing.js | @@ -61,9 +61,8 @@ var RoutingService = Service.extend({
return router.generate.apply(router, args);
},
- isActiveForRoute: function(params, routeName, routerState, isCurrentWhenSpecified) {
+ isActiveForRoute: function(contexts, queryParams, routeName, routerState, isCurrentWhenSpecified) {
var router = get(this, 'router');
- var contexts = params.models;
var handlers = router.router.recognizer.handlersFor(routeName);
var leafName = handlers[handlers.length-1].handler;
@@ -83,7 +82,7 @@ var RoutingService = Service.extend({
routeName = leafName;
}
- return routerState.isActiveIntent(routeName, contexts, params.queryParams, !isCurrentWhenSpecified);
+ return routerState.isActiveIntent(routeName, contexts, queryParams, !isCurrentWhenSpecified);
}
});
| true |
Other | emberjs | ember.js | f75b2e11955e0eb84af08039d90cdf1203465494.json | Unify component creation
Previously, we had in place three different methods for inserting views
or components into the render hierarchy. Top-level views went through
a legacy path that used RenderBuffer. Outlet’s went through our
abandoned ShadowRoot abstraction. The `{{view}}` helper and non-top-
level components went through ComponentNode.
While this commit started as an attempt to implement `{{link-to}}`, it
ended up being an exercise in unifying the above paths to just use
ComponentNode, which is itself simplified in this commit.
In order to support LinkView, we also implemented the view’s
`classNameBindings` syntax. In our approach, we dynamically translate
the `classNameBindings` microsyntax into the HTMLBars statements, then
use those to build a template that represents the view’s wrapping
element at runtime.
Once we had the class name bindings working, we were able to rewrite
the path for top-level views to use ComponentNodes. This allowed us to
remove large amounts of legacy view code, and there is almost assuredly
more code that we can now audit and remove entirely.
* Added registerKeyword facility
* Implemented classNameBindings
* Added `link` hook to keywords
* Rewrote `{{outlet}}` to use ComponentNode
* Added utility for building component templates (with nested blocks)
* Changed hook invocation order (`willRender` comes after
`willReceiveAttrs`)
* Top-level views now render through ComponentNode rather than legacy
RenderBuffer code path.
* Added zipHash stream utility
* Implemented largely working `LinkView`/`{{link-to}}` | packages/ember-views/lib/mixins/template_rendering_support.js | @@ -28,12 +28,12 @@ var TemplateRenderingSupport = Mixin.create({
// TODO: Legacy string render function support
},
- renderTemplate() {
+ renderBlock(block, renderNode) {
if (_renderView === undefined) {
_renderView = require('ember-htmlbars/system/render-view');
}
- return _renderView.renderHTMLBarsTemplate.apply(this, arguments);
+ return _renderView.renderHTMLBarsBlock(this, block, renderNode);
}
});
| true |
Other | emberjs | ember.js | f75b2e11955e0eb84af08039d90cdf1203465494.json | Unify component creation
Previously, we had in place three different methods for inserting views
or components into the render hierarchy. Top-level views went through
a legacy path that used RenderBuffer. Outlet’s went through our
abandoned ShadowRoot abstraction. The `{{view}}` helper and non-top-
level components went through ComponentNode.
While this commit started as an attempt to implement `{{link-to}}`, it
ended up being an exercise in unifying the above paths to just use
ComponentNode, which is itself simplified in this commit.
In order to support LinkView, we also implemented the view’s
`classNameBindings` syntax. In our approach, we dynamically translate
the `classNameBindings` microsyntax into the HTMLBars statements, then
use those to build a template that represents the view’s wrapping
element at runtime.
Once we had the class name bindings working, we were able to rewrite
the path for top-level views to use ComponentNodes. This allowed us to
remove large amounts of legacy view code, and there is almost assuredly
more code that we can now audit and remove entirely.
* Added registerKeyword facility
* Implemented classNameBindings
* Added `link` hook to keywords
* Rewrote `{{outlet}}` to use ComponentNode
* Added utility for building component templates (with nested blocks)
* Changed hook invocation order (`willRender` comes after
`willReceiveAttrs`)
* Top-level views now render through ComponentNode rather than legacy
RenderBuffer code path.
* Added zipHash stream utility
* Implemented largely working `LinkView`/`{{link-to}}` | packages/ember-views/lib/system/build-component-template.js | @@ -0,0 +1,286 @@
+import { internal, render } from "htmlbars-runtime";
+import { read } from "ember-metal/streams/utils";
+import { get } from "ember-metal/property_get";
+
+export default function buildComponentTemplate(componentInfo, attrs, content) {
+ var component, layoutTemplate, contentBlock, blockToRender;
+ var createdElementBlock = false;
+
+ component = componentInfo.component;
+
+ if (component) {
+ var tagName = tagNameFor(component);
+
+ layoutTemplate = get(component, 'layout') || componentInfo.layout;
+
+ var layoutBlock;
+
+ if (content.template) {
+ contentBlock = internal.blockFor(render, content.template, {
+ scope: content.scope,
+ self: content.scope ? undefined : content.self || {},
+ options: { view: component }
+ });
+ } else {
+ contentBlock = function() {};
+ }
+
+ if (layoutTemplate) {
+ layoutBlock = internal.blockFor(render, layoutTemplate.raw, {
+ yieldTo: contentBlock,
+ self: content.self || {},
+ options: { view: component, attrs: attrs }
+ });
+ }
+
+ if (tagName !== '') {
+ var attributes = normalizeComponentAttributes(component, attrs);
+ var elementTemplate = internal.manualElement(tagName, attributes);
+
+ createdElementBlock = true;
+
+ blockToRender = internal.blockFor(render, elementTemplate, {
+ yieldTo: layoutBlock || contentBlock,
+ self: { view: component },
+ options: { view: component }
+ });
+ } else {
+ blockToRender = layoutBlock || contentBlock;
+ }
+ } else {
+ contentBlock = internal.blockFor(render, content.template, {
+ scope: content.scope,
+ self: content.scope ? undefined : {}
+ });
+
+ blockToRender = internal.blockFor(render, componentInfo.layout.raw, {
+ yieldTo: contentBlock,
+ self: {},
+ options: { view: component, attrs: attrs }
+ });
+ }
+
+ return { createdElement: createdElementBlock, block: blockToRender };
+}
+
+function tagNameFor(view) {
+ var tagName = view.tagName;
+
+ if (tagName !== null && typeof tagName === 'object' && tagName.isDescriptor) {
+ tagName = get(view, 'tagName');
+ Ember.deprecate('In the future using a computed property to define tagName will not be permitted. That value will be respected, but changing it will not update the element.', !tagName);
+ }
+
+ if (tagName === null || tagName === undefined) {
+ tagName = 'div';
+ }
+
+ return tagName;
+}
+
+// Takes a component and builds a normalized set of attribute
+// bindings consumable by HTMLBars' `attribute` hook.
+function normalizeComponentAttributes(component, attrs) {
+ var normalized = {};
+ var attributeBindings = component.attributeBindings;
+ var i, l;
+
+ if (attributeBindings) {
+ for (i=0, l=attributeBindings.length; i<l; i++) {
+ var attr = attributeBindings[i];
+ var microsyntax = attr.split(':');
+
+ if (microsyntax[1]) {
+ normalized[microsyntax[1]] = ['get', 'view.' + microsyntax[0]];
+ } else if (attrs[attr]) {
+ normalized[attr] = ['value', attrs[attr]];
+ } else {
+ normalized[attr] = ['get', 'view.' + attr];
+ }
+ }
+ }
+
+ if (attrs.id) {
+ // Do not allow binding to the `id`
+ normalized.id = read(attrs.id);
+ component.elementId = normalized.id;
+ } else {
+ normalized.id = component.elementId;
+ }
+
+ if (attrs.tagName) {
+ component.tagName = attrs.tagName;
+ }
+
+ var normalizedClass = normalizeClass(component, attrs.class);
+
+ if (normalizedClass) {
+ normalized.class = normalizedClass;
+ }
+
+ return normalized;
+}
+
+function normalizeClass(component, classAttr) {
+ var i, l;
+ var normalizedClass = [];
+ var classNames = get(component, 'classNames');
+ var classNameBindings = get(component, 'classNameBindings');
+
+ if (classAttr) {
+ normalizedClass.push(['value', classAttr]);
+ }
+
+ if (classNames) {
+ for (i=0, l=classNames.length; i<l; i++) {
+ normalizedClass.push(classNames[i]);
+ }
+ }
+
+ if (classNameBindings) {
+ for (i=0, l=classNameBindings.length; i<l; i++) {
+ var className = classNameBindings[i];
+ var microsyntax = className.split(':');
+ var prop = 'view.' + microsyntax[0];
+ var activeClass, inactiveClass;
+
+ if (microsyntax.length === 1) {
+ activeClass = prop;
+ } else if (microsyntax.length === 2) {
+ activeClass = microsyntax[1];
+ } else {
+ activeClass = microsyntax[1];
+ inactiveClass = microsyntax[2];
+ }
+
+ normalizedClass.push(['subexpr', '-normalize-class', [
+ // params
+ ['get', prop]
+ ], [
+ // hash
+ 'activeClass', activeClass,
+ 'inactiveClass', inactiveClass
+ ]]);
+ }
+ }
+
+ var last = normalizedClass.length - 1;
+ var output = [];
+ for (i=0, l=normalizedClass.length; i<l; i++) {
+ output.push(normalizedClass[i]);
+ if (i !== last) { output.push(' '); }
+ }
+
+ if (output.length) {
+ return ['concat', output];
+ }
+}
+function normalizeClass(component, classAttr) {
+ var i, l;
+ var normalizedClass = [];
+ var classNames = get(component, 'classNames');
+ var classNameBindings = get(component, 'classNameBindings');
+
+ if (classAttr) {
+ normalizedClass.push(['value', classAttr]);
+ }
+
+ if (classNames) {
+ for (i=0, l=classNames.length; i<l; i++) {
+ normalizedClass.push(classNames[i]);
+ }
+ }
+
+ if (classNameBindings) {
+ for (i=0, l=classNameBindings.length; i<l; i++) {
+ var className = classNameBindings[i];
+ var microsyntax = className.split(':');
+ var prop = 'view.' + microsyntax[0];
+ var activeClass, inactiveClass;
+
+ if (microsyntax.length === 1) {
+ activeClass = prop;
+ } else if (microsyntax.length === 2) {
+ activeClass = microsyntax[1];
+ } else {
+ activeClass = microsyntax[1];
+ inactiveClass = microsyntax[2];
+ }
+
+ normalizedClass.push(['subexpr', '-normalize-class', [
+ // params
+ ['get', prop]
+ ], [
+ // hash
+ 'activeClass', activeClass,
+ 'inactiveClass', inactiveClass
+ ]]);
+ }
+ }
+
+ var last = normalizedClass.length - 1;
+ var output = [];
+ for (i=0, l=normalizedClass.length; i<l; i++) {
+ output.push(normalizedClass[i]);
+ if (i !== last) { output.push(' '); }
+ }
+
+ if (output.length) {
+ return ['concat', output];
+ }
+}
+
+function normalizeClass(component, classAttr) {
+ var i, l;
+ var normalizedClass = [];
+ var classNames = get(component, 'classNames');
+ var classNameBindings = get(component, 'classNameBindings');
+
+ if (classAttr) {
+ normalizedClass.push(['value', classAttr]);
+ }
+
+ if (classNames) {
+ for (i=0, l=classNames.length; i<l; i++) {
+ normalizedClass.push(classNames[i]);
+ }
+ }
+
+ if (classNameBindings) {
+ for (i=0, l=classNameBindings.length; i<l; i++) {
+ var className = classNameBindings[i];
+ var microsyntax = className.split(':');
+ var prop = 'view.' + microsyntax[0];
+ var activeClass, inactiveClass;
+
+ if (microsyntax.length === 1) {
+ activeClass = prop;
+ } else if (microsyntax.length === 2) {
+ activeClass = microsyntax[1];
+ } else {
+ activeClass = microsyntax[1];
+ inactiveClass = microsyntax[2];
+ }
+
+ normalizedClass.push(['subexpr', '-normalize-class', [
+ // params
+ ['get', prop]
+ ], [
+ // hash
+ 'activeClass', activeClass,
+ 'inactiveClass', inactiveClass
+ ]]);
+ }
+ }
+
+ var last = normalizedClass.length - 1;
+ var output = [];
+ for (i=0, l=normalizedClass.length; i<l; i++) {
+ output.push(normalizedClass[i]);
+ if (i !== last) { output.push(' '); }
+ }
+
+ if (output.length) {
+ return ['concat', output];
+ }
+} | true |
Other | emberjs | ember.js | f75b2e11955e0eb84af08039d90cdf1203465494.json | Unify component creation
Previously, we had in place three different methods for inserting views
or components into the render hierarchy. Top-level views went through
a legacy path that used RenderBuffer. Outlet’s went through our
abandoned ShadowRoot abstraction. The `{{view}}` helper and non-top-
level components went through ComponentNode.
While this commit started as an attempt to implement `{{link-to}}`, it
ended up being an exercise in unifying the above paths to just use
ComponentNode, which is itself simplified in this commit.
In order to support LinkView, we also implemented the view’s
`classNameBindings` syntax. In our approach, we dynamically translate
the `classNameBindings` microsyntax into the HTMLBars statements, then
use those to build a template that represents the view’s wrapping
element at runtime.
Once we had the class name bindings working, we were able to rewrite
the path for top-level views to use ComponentNodes. This allowed us to
remove large amounts of legacy view code, and there is almost assuredly
more code that we can now audit and remove entirely.
* Added registerKeyword facility
* Implemented classNameBindings
* Added `link` hook to keywords
* Rewrote `{{outlet}}` to use ComponentNode
* Added utility for building component templates (with nested blocks)
* Changed hook invocation order (`willRender` comes after
`willReceiveAttrs`)
* Top-level views now render through ComponentNode rather than legacy
RenderBuffer code path.
* Added zipHash stream utility
* Implemented largely working `LinkView`/`{{link-to}}` | packages/ember/tests/helpers/link_to_test.js | @@ -193,10 +193,7 @@ QUnit.test("the {{link-to}} doesn't apply a 'disabled' class if disabledWhen is
});
QUnit.test("the {{link-to}} helper supports a custom disabledClass", function () {
- Ember.TEMPLATES.index = compile('{{#link-to "about" id="about-link" disabledWhen="shouldDisable" disabledClass="do-not-want"}}About{{/link-to}}');
- App.IndexController = Ember.Controller.extend({
- shouldDisable: true
- });
+ Ember.TEMPLATES.index = compile('{{#link-to "about" id="about-link" disabledWhen=true disabledClass="do-not-want"}}About{{/link-to}}');
Router.map(function() {
this.route("about");
@@ -213,10 +210,7 @@ QUnit.test("the {{link-to}} helper supports a custom disabledClass", function ()
});
QUnit.test("the {{link-to}} helper does not respond to clicks when disabled", function () {
- Ember.TEMPLATES.index = compile('{{#link-to "about" id="about-link" disabledWhen="shouldDisable"}}About{{/link-to}}');
- App.IndexController = Ember.Controller.extend({
- shouldDisable: true
- });
+ Ember.TEMPLATES.index = compile('{{#link-to "about" id="about-link" disabledWhen=true}}About{{/link-to}}');
Router.map(function() {
this.route("about");
@@ -449,7 +443,7 @@ QUnit.test("The {{link-to}} helper moves into the named route with context", fun
this.resource("item", { path: "/item/:id" });
});
- Ember.TEMPLATES.about = compile("<h3>List</h3><ul>{{#each person in model}}<li>{{#link-to 'item' person}}{{person.name}}{{/link-to}}</li>{{/each}}</ul>{{#link-to 'index' id='home-link'}}Home{{/link-to}}");
+ Ember.TEMPLATES.about = compile("<h3>List</h3><ul>{{#each model as |person|}}<li>{{#link-to 'item' person}}{{person.name}}{{/link-to}}</li>{{/each}}</ul>{{#link-to 'index' id='home-link'}}Home{{/link-to}}");
App.AboutRoute = Ember.Route.extend({
model() { | true |
Other | emberjs | ember.js | 7cff945c04bf66b0c621b6b70042c51d8a5b2cdf.json | Introduce routing service
This commit introduces a new routing service, so that we can decouple
`LinkView` from knowing about the actual router’s internals.
Before this commit, LinkView tried to find the router off of its
controller, and looked up the application controller to get current
router state. This commit creates an initial API for working with a
single uniform service that provides the information.
The implementation of the routing service is not yet ready to be made a
public API, but it should be possible to expose once it stabilizes
further. The long-term goal is to provide a robust enough service that
end users could relatively easily implement their own LinkView using
public APIs. | packages/ember-routing-htmlbars/tests/helpers/link-to_test.js | @@ -4,11 +4,32 @@ import EmberView from "ember-views/views/view";
import compile from "ember-template-compiler/system/compile";
import { set } from "ember-metal/property_set";
import Controller from "ember-runtime/controllers/controller";
+import { Registry } from "ember-runtime/system/container";
import { runAppend, runDestroy } from "ember-runtime/tests/utils";
+import EmberObject from "ember-runtime/system/object";
var view;
+var container;
+var registry = new Registry();
+
+// These tests don't rely on the routing service, but LinkView makes
+// some assumptions that it will exist. This small stub service ensures
+// that the LinkView can render without raising an exception.
+//
+// TODO: Add tests that test actual behavior. Currently, all behavior
+// is tested integration-style in the `ember` package.
+registry.register('service:-routing', EmberObject.extend({
+ availableRoutes: function() { return ['index']; },
+ hasRoute: function(name) { return name === 'index'; },
+ isActiveForRoute: function() { return true; },
+ generateURL: function() { return "/"; }
+}));
QUnit.module("ember-routing-htmlbars: link-to helper", {
+ setup() {
+ container = registry.container();
+ },
+
teardown() {
runDestroy(view);
}
@@ -18,7 +39,8 @@ QUnit.module("ember-routing-htmlbars: link-to helper", {
QUnit.test("should be able to be inserted in DOM when the router is not present", function() {
var template = "{{#link-to 'index'}}Go to Index{{/link-to}}";
view = EmberView.create({
- template: compile(template)
+ template: compile(template),
+ container: container
});
runAppend(view);
@@ -33,7 +55,8 @@ QUnit.test("re-renders when title changes", function() {
title: 'foo',
routeName: 'index'
},
- template: compile(template)
+ template: compile(template),
+ container: container
});
runAppend(view);
@@ -54,7 +77,8 @@ QUnit.test("can read bound title", function() {
title: 'foo',
routeName: 'index'
},
- template: compile(template)
+ template: compile(template),
+ container: container
});
runAppend(view);
@@ -65,7 +89,8 @@ QUnit.test("can read bound title", function() {
QUnit.test("escaped inline form (double curlies) escapes link title", function() {
view = EmberView.create({
title: "<b>blah</b>",
- template: compile("{{link-to view.title}}")
+ template: compile("{{link-to view.title}}"),
+ container: container
});
runAppend(view);
@@ -76,7 +101,8 @@ QUnit.test("escaped inline form (double curlies) escapes link title", function()
QUnit.test("unescaped inline form (triple curlies) does not escape link title", function() {
view = EmberView.create({
title: "<b>blah</b>",
- template: compile("{{{link-to view.title}}}")
+ template: compile("{{{link-to view.title}}}"),
+ container: container
});
runAppend(view);
@@ -92,7 +118,8 @@ QUnit.test("unwraps controllers", function() {
model: 'foo'
}),
- template: compile(template)
+ template: compile(template),
+ container: container
});
expectDeprecation(function() { | true |
Other | emberjs | ember.js | 7cff945c04bf66b0c621b6b70042c51d8a5b2cdf.json | Introduce routing service
This commit introduces a new routing service, so that we can decouple
`LinkView` from knowing about the actual router’s internals.
Before this commit, LinkView tried to find the router off of its
controller, and looked up the application controller to get current
router state. This commit creates an initial API for working with a
single uniform service that provides the information.
The implementation of the routing service is not yet ready to be made a
public API, but it should be possible to expose once it stabilizes
further. The long-term goal is to provide a robust enough service that
end users could relatively easily implement their own LinkView using
public APIs. | packages/ember-routing-views/lib/views/link.js | @@ -6,27 +6,12 @@
import Ember from "ember-metal/core"; // FEATURES, Logger, assert
import { get } from "ember-metal/property_get";
-import merge from "ember-metal/merge";
-import run from "ember-metal/run_loop";
import { computed } from "ember-metal/computed";
import { fmt } from "ember-runtime/system/string";
-import keys from "ember-metal/keys";
import { isSimpleClick } from "ember-views/system/utils";
import EmberComponent from "ember-views/views/component";
-import { routeArgs } from "ember-routing/utils";
import { read, subscribe } from "ember-metal/streams/utils";
-
-var numberOfContextsAcceptedByHandler = function(handler, handlerInfos) {
- var req = 0;
- for (var i = 0, l = handlerInfos.length; i < l; i++) {
- req = req + handlerInfos[i].names.length;
- if (handlerInfos[i].handler === handler) {
- break;
- }
- }
-
- return req;
-};
+import inject from "ember-runtime/inject";
var linkViewClassNameBindings = ['active', 'loading', 'disabled'];
if (Ember.FEATURES.isEnabled('ember-routing-transitioning-classes')) {
@@ -216,6 +201,8 @@ var LinkView = EmberComponent.extend({
this.on(eventName, this, this._invoke);
},
+ _routing: inject.service('-routing'),
+
/**
This method is invoked by observers installed during `init` that fire
whenever the params change
@@ -295,16 +282,14 @@ var LinkView = EmberComponent.extend({
@property active
**/
active: computed('loadedParams', function computeLinkViewActive() {
- var router = get(this, 'router');
- if (!router) { return; }
- return computeActive(this, router.currentState);
+ var currentState = get(this, '_routing.currentState');
+ return computeActive(this, currentState);
}),
- willBeActive: computed('router.targetState', function() {
- var router = get(this, 'router');
- if (!router) { return; }
- var targetState = router.targetState;
- if (router.currentState === targetState) { return; }
+ willBeActive: computed('_routing.targetState', function() {
+ var routing = get(this, '_routing');
+ var targetState = get(routing, 'targetState');
+ if (get(routing, 'currentState') === targetState) { return; }
return !!computeActive(this, targetState);
}),
@@ -338,19 +323,6 @@ var LinkView = EmberComponent.extend({
if (!get(this, 'loadedParams')) { return get(this, 'loadingClass'); }
}),
- /**
- Returns the application's main router from the container.
-
- @private
- @property router
- **/
- router: computed(function() {
- var controller = get(this, 'controller');
- if (controller && controller.container) {
- return controller.container.lookup('router:main');
- }
- }),
-
/**
Event handler that invokes the link, activating the associated route.
@@ -382,57 +354,8 @@ var LinkView = EmberComponent.extend({
return false;
}
- var router = get(this, 'router');
- var loadedParams = get(this, 'loadedParams');
-
- var transition = router._doTransition(loadedParams.targetRouteName, loadedParams.models, loadedParams.queryParams);
- if (get(this, 'replace')) {
- transition.method('replace');
- }
-
- if (Ember.FEATURES.isEnabled('ember-routing-transitioning-classes')) {
- return;
- }
-
- // Schedule eager URL update, but after we've given the transition
- // a chance to synchronously redirect.
- // We need to always generate the URL instead of using the href because
- // the href will include any rootURL set, but the router expects a URL
- // without it! Note that we don't use the first level router because it
- // calls location.formatURL(), which also would add the rootURL!
- var args = routeArgs(loadedParams.targetRouteName, loadedParams.models, transition.state.queryParams);
- var url = router.router.generate.apply(router.router, args);
-
- run.scheduleOnce('routerTransitions', this, this._eagerUpdateUrl, transition, url);
- },
-
- /**
- @private
- @method _eagerUpdateUrl
- @param transition
- @param href
- */
- _eagerUpdateUrl(transition, href) {
- if (!transition.isActive || !transition.urlMethod) {
- // transition was aborted, already ran to completion,
- // or it has a null url-updated method.
- return;
- }
-
- if (href.indexOf('#') === 0) {
- href = href.slice(1);
- }
-
- // Re-use the routerjs hooks set up by the Ember router.
- var routerjs = get(this, 'router.router');
- if (transition.urlMethod === 'update') {
- routerjs.updateURL(href);
- } else if (transition.urlMethod === 'replace') {
- routerjs.replaceURL(href);
- }
-
- // Prevent later update url refire.
- transition.method(null);
+ var params = get(this, 'loadedParams');
+ get(this, '_routing').transitionTo(params.targetRouteName, params.models, params.queryParams, get(this, 'replace'));
},
/**
@@ -454,15 +377,14 @@ var LinkView = EmberComponent.extend({
@property
@return {Array}
*/
- resolvedParams: computed('router.url', function() {
+ resolvedParams: computed('_routing.currentState', function() {
var params = this.params;
var targetRouteName;
var models = [];
var onlyQueryParamsSupplied = (params.length === 0);
if (onlyQueryParamsSupplied) {
- var appController = this.container.lookup('controller:application');
- targetRouteName = get(appController, 'currentRouteName');
+ targetRouteName = get(this, '_routing.currentRouteName');
} else {
targetRouteName = read(params[0]);
@@ -491,8 +413,8 @@ var LinkView = EmberComponent.extend({
@return {Array} An array with the route name and any dynamic segments
**/
loadedParams: computed('resolvedParams', function computeLinkViewRouteArgs() {
- var router = get(this, 'router');
- if (!router) { return; }
+ var routing = get(this, '_routing');
+ if (!routing) { return; }
var resolvedParams = get(this, 'resolvedParams');
var namedRoute = resolvedParams.targetRouteName;
@@ -501,8 +423,8 @@ var LinkView = EmberComponent.extend({
Ember.assert(fmt("The attempt to link-to route '%@' failed. " +
"The router did not find '%@' in its possible routes: '%@'",
- [namedRoute, namedRoute, keys(router.router.recognizer.names).join("', '")]),
- router.hasRoute(namedRoute));
+ [namedRoute, namedRoute, routing.availableRoutes().join("', '")]),
+ routing.hasRoute(namedRoute));
if (!paramsAreLoaded(resolvedParams.models)) { return; }
@@ -523,20 +445,14 @@ var LinkView = EmberComponent.extend({
href: computed('loadedParams', function computeLinkViewHref() {
if (get(this, 'tagName') !== 'a') { return; }
- var router = get(this, 'router');
- var loadedParams = get(this, 'loadedParams');
+ var routing = get(this, '_routing');
+ var params = get(this, 'loadedParams');
- if (!loadedParams) {
+ if (!params) {
return get(this, 'loadingHref');
}
- var visibleQueryParams = {};
- merge(visibleQueryParams, loadedParams.queryParams);
- router._prepareQueryParams(loadedParams.targetRouteName, loadedParams.models, visibleQueryParams);
-
- var args = routeArgs(loadedParams.targetRouteName, loadedParams.models, visibleQueryParams);
- var result = router.generate.apply(router, args);
- return result;
+ return routing.generateURL(params.targetRouteName, params.models, params.queryParams);
}),
/**
@@ -577,46 +493,26 @@ function paramsAreLoaded(params) {
return true;
}
-function computeActive(route, routerState) {
- if (get(route, 'loading')) { return false; }
+function computeActive(view, routerState) {
+ if (get(view, 'loading')) { return false; }
- var currentWhen = route['current-when'] || route.currentWhen;
+ var currentWhen = view['current-when'] || view.currentWhen;
var isCurrentWhenSpecified = !!currentWhen;
- currentWhen = currentWhen || get(route, 'loadedParams').targetRouteName;
+ currentWhen = currentWhen || get(view, 'loadedParams').targetRouteName;
currentWhen = currentWhen.split(' ');
for (var i = 0, len = currentWhen.length; i < len; i++) {
- if (isActiveForRoute(route, currentWhen[i], isCurrentWhenSpecified, routerState)) {
- return get(route, 'activeClass');
+ if (isActiveForRoute(view, currentWhen[i], isCurrentWhenSpecified, routerState)) {
+ return get(view, 'activeClass');
}
}
return false;
}
-function isActiveForRoute(route, routeName, isCurrentWhenSpecified, routerState) {
- var router = get(route, 'router');
- var loadedParams = get(route, 'loadedParams');
- var contexts = loadedParams.models;
-
- var handlers = router.router.recognizer.handlersFor(routeName);
- var leafName = handlers[handlers.length-1].handler;
- var maximumContexts = numberOfContextsAcceptedByHandler(routeName, handlers);
-
- // NOTE: any ugliness in the calculation of activeness is largely
- // due to the fact that we support automatic normalizing of
- // `resource` -> `resource.index`, even though there might be
- // dynamic segments / query params defined on `resource.index`
- // which complicates (and makes somewhat ambiguous) the calculation
- // of activeness for links that link to `resource` instead of
- // directly to `resource.index`.
-
- // if we don't have enough contexts revert back to full route name
- // this is because the leaf route will use one of the contexts
- if (contexts.length > maximumContexts) {
- routeName = leafName;
- }
-
- return routerState.isActiveIntent(routeName, contexts, loadedParams.queryParams, !isCurrentWhenSpecified);
+function isActiveForRoute(view, routeName, isCurrentWhenSpecified, routerState) {
+ var params = get(view, 'loadedParams');
+ var service = get(view, '_routing');
+ return service.isActiveForRoute(params, routeName, routerState, isCurrentWhenSpecified);
}
export { | true |
Other | emberjs | ember.js | 7cff945c04bf66b0c621b6b70042c51d8a5b2cdf.json | Introduce routing service
This commit introduces a new routing service, so that we can decouple
`LinkView` from knowing about the actual router’s internals.
Before this commit, LinkView tried to find the router off of its
controller, and looked up the application controller to get current
router state. This commit creates an initial API for working with a
single uniform service that provides the information.
The implementation of the routing service is not yet ready to be made a
public API, but it should be possible to expose once it stabilizes
further. The long-term goal is to provide a robust enough service that
end users could relatively easily implement their own LinkView using
public APIs. | packages/ember-routing/lib/initializers/routing-service.js | @@ -0,0 +1,14 @@
+import { onLoad } from "ember-runtime/system/lazy_load";
+import RoutingService from "ember-routing/services/routing";
+
+onLoad('Ember.Application', function(Application) {
+ Application.initializer({
+ name: 'routing-service',
+ initialize: function(registry) {
+ // Register the routing service...
+ registry.register('service:-routing', RoutingService);
+ // Then inject the app router into it
+ registry.injection('service:-routing', 'router', 'router:main');
+ }
+ });
+}); | true |
Other | emberjs | ember.js | 7cff945c04bf66b0c621b6b70042c51d8a5b2cdf.json | Introduce routing service
This commit introduces a new routing service, so that we can decouple
`LinkView` from knowing about the actual router’s internals.
Before this commit, LinkView tried to find the router off of its
controller, and looked up the application controller to get current
router state. This commit creates an initial API for working with a
single uniform service that provides the information.
The implementation of the routing service is not yet ready to be made a
public API, but it should be possible to expose once it stabilizes
further. The long-term goal is to provide a robust enough service that
end users could relatively easily implement their own LinkView using
public APIs. | packages/ember-routing/lib/main.js | @@ -27,6 +27,8 @@ import RouterDSL from "ember-routing/system/dsl";
import Router from "ember-routing/system/router";
import Route from "ember-routing/system/route";
+import "ember-routing/initializers/routing-service";
+
Ember.Location = EmberLocation;
Ember.AutoLocation = AutoLocation;
Ember.HashLocation = HashLocation; | true |
Other | emberjs | ember.js | 7cff945c04bf66b0c621b6b70042c51d8a5b2cdf.json | Introduce routing service
This commit introduces a new routing service, so that we can decouple
`LinkView` from knowing about the actual router’s internals.
Before this commit, LinkView tried to find the router off of its
controller, and looked up the application controller to get current
router state. This commit creates an initial API for working with a
single uniform service that provides the information.
The implementation of the routing service is not yet ready to be made a
public API, but it should be possible to expose once it stabilizes
further. The long-term goal is to provide a robust enough service that
end users could relatively easily implement their own LinkView using
public APIs. | packages/ember-routing/lib/services/routing.js | @@ -0,0 +1,102 @@
+/**
+@module ember
+@submodule ember-routing
+*/
+
+import Service from "ember-runtime/system/service";
+
+import { get } from "ember-metal/property_get";
+import { readOnly } from "ember-metal/computed_macros";
+import { routeArgs } from "ember-routing/utils";
+import keys from "ember-metal/keys";
+import merge from "ember-metal/merge";
+
+/** @private
+ The Routing service is used by LinkView, and provides facilities for
+ the component/view layer to interact with the router.
+
+ While still private, this service can eventually be opened up, and provides
+ the set of API needed for components to control routing without interacting
+ with router internals.
+*/
+
+var RoutingService = Service.extend({
+ router: null,
+
+ targetState: readOnly('router.targetState'),
+ currentState: readOnly('router.currentState'),
+ currentRouteName: readOnly('router.currentRouteName'),
+
+ availableRoutes: function() {
+ return keys(get(this, 'router').router.recognizer.names);
+ },
+
+ hasRoute: function(routeName) {
+ return get(this, 'router').hasRoute(routeName);
+ },
+
+ transitionTo: function(routeName, models, queryParams, shouldReplace) {
+ var router = get(this, 'router');
+
+ var transition = router._doTransition(routeName, models, queryParams);
+
+ if (shouldReplace) {
+ transition.method('replace');
+ }
+ },
+
+ normalizeQueryParams: function(routeName, models, queryParams) {
+ get(this, 'router')._prepareQueryParams(routeName, models, queryParams);
+ },
+
+ generateURL: function(routeName, models, queryParams) {
+ var router = get(this, 'router');
+
+ var visibleQueryParams = {};
+ merge(visibleQueryParams, queryParams);
+
+ this.normalizeQueryParams(routeName, models, visibleQueryParams);
+
+ var args = routeArgs(routeName, models, visibleQueryParams);
+ return router.generate.apply(router, args);
+ },
+
+ isActiveForRoute: function(params, routeName, routerState, isCurrentWhenSpecified) {
+ var router = get(this, 'router');
+ var contexts = params.models;
+
+ var handlers = router.router.recognizer.handlersFor(routeName);
+ var leafName = handlers[handlers.length-1].handler;
+ var maximumContexts = numberOfContextsAcceptedByHandler(routeName, handlers);
+
+ // NOTE: any ugliness in the calculation of activeness is largely
+ // due to the fact that we support automatic normalizing of
+ // `resource` -> `resource.index`, even though there might be
+ // dynamic segments / query params defined on `resource.index`
+ // which complicates (and makes somewhat ambiguous) the calculation
+ // of activeness for links that link to `resource` instead of
+ // directly to `resource.index`.
+
+ // if we don't have enough contexts revert back to full route name
+ // this is because the leaf route will use one of the contexts
+ if (contexts.length > maximumContexts) {
+ routeName = leafName;
+ }
+
+ return routerState.isActiveIntent(routeName, contexts, params.queryParams, !isCurrentWhenSpecified);
+ }
+});
+
+var numberOfContextsAcceptedByHandler = function(handler, handlerInfos) {
+ var req = 0;
+ for (var i = 0, l = handlerInfos.length; i < l; i++) {
+ req = req + handlerInfos[i].names.length;
+ if (handlerInfos[i].handler === handler) {
+ break;
+ }
+ }
+
+ return req;
+};
+
+export default RoutingService; | true |
Other | emberjs | ember.js | 7cff945c04bf66b0c621b6b70042c51d8a5b2cdf.json | Introduce routing service
This commit introduces a new routing service, so that we can decouple
`LinkView` from knowing about the actual router’s internals.
Before this commit, LinkView tried to find the router off of its
controller, and looked up the application controller to get current
router state. This commit creates an initial API for working with a
single uniform service that provides the information.
The implementation of the routing service is not yet ready to be made a
public API, but it should be possible to expose once it stabilizes
further. The long-term goal is to provide a robust enough service that
end users could relatively easily implement their own LinkView using
public APIs. | packages/ember-routing/lib/system/router.js | @@ -875,12 +875,14 @@ function updatePaths(router) {
}
set(appController, 'currentPath', path);
+ set(router, 'currentPath', path);
if (!('currentRouteName' in appController)) {
defineProperty(appController, 'currentRouteName');
}
set(appController, 'currentRouteName', infos[infos.length - 1].name);
+ set(router, 'currentRouteName', infos[infos.length - 1].name);
}
EmberRouter.reopenClass({ | true |
Other | emberjs | ember.js | 93d42e327425a9ae776fe200469b3048d47ef63d.json | Update linkRenderNode signature | packages/ember-htmlbars/lib/hooks/link-render-node.js | @@ -7,7 +7,7 @@ import subscribe from "ember-htmlbars/utils/subscribe";
import shouldDisplay from "ember-views/streams/should_display";
import { chain, read } from "ember-metal/streams/utils";
-export default function linkRenderNode(renderNode, scope, path, params, hash) {
+export default function linkRenderNode(renderNode, env, scope, path, params, hash) {
if (renderNode.state.unsubscribers) {
return true;
} | false |
Other | emberjs | ember.js | 7bb4a5bb8339c0aa0db9afe707989a6fd4aecef7.json | Fix some bugs in KeyStream | packages/ember-metal/lib/streams/key-stream.js | @@ -18,33 +18,39 @@ function KeyStream(source, key) {
this.init();
this.source = source;
- this.obj = undefined;
+ this.dependency = this.addDependency(source);
+ this.observedObject = undefined;
this.key = key;
}
KeyStream.prototype = create(Stream.prototype);
merge(KeyStream.prototype, {
compute() {
- var obj = read(this.source);
- if (obj) {
- return get(obj, this.key);
+ var object = read(this.source);
+ if (object) {
+ return get(object, this.key);
}
},
becameActive() {
- if (this.obj && typeof this.obj === 'object') {
- addObserver(this.obj, this.key, this, this.notify);
+ var object = read(this.source);
+ if (object && typeof object === 'object') {
+ addObserver(object, this.key, this, this.notify);
+ this.observedObject = object;
}
- if (nextObj) {
- return get(nextObj, this.key);
+ becameInactive() {
+ if (this.observedObject) {
+ removeObserver(this.observedObject, this.key, this, this.notify);
+ this.observedObject = undefined;
}
},
setValue(value) {
- if (this.obj) {
- set(this.obj, this.key, value);
+ var object = read(this.source);
+ if (object) {
+ set(object, this.key, value);
}
},
@@ -57,7 +63,6 @@ merge(KeyStream.prototype, {
this.update(function() {
this.dependency.replace(nextSource);
this.source = nextSource;
- this.obj = read(nextSource);
});
}
@@ -81,7 +86,6 @@ merge(KeyStream.prototype, {
}
this.source = undefined;
- this.obj = undefined;
return true;
}
} | false |
Other | emberjs | ember.js | b3f592aa6c605d7e12f2f009eb3bdb1aaae8b36d.json | Add KeyStream tests | packages/ember-metal/tests/streams/key-stream-test.js | @@ -1,33 +1,109 @@
import Stream from "ember-metal/streams/stream";
import KeyStream from "ember-metal/streams/key-stream";
+import { set } from "ember-metal/property_set";
-var source, value;
+var source, object, count;
+
+function incrementCount() {
+ count++;
+}
QUnit.module('KeyStream', {
setup: function() {
- value = { foo: "zlurp" };
+ count = 0;
+ object = { name: "mmun" };
source = new Stream(function() {
- return value;
+ return object;
});
- source.setValue = function(_value) {
- value = _value;
+ source.setValue = function(value) {
+ object = value;
this.notify();
};
},
teardown: function() {
- value = undefined;
+ count = undefined;
+ object = undefined;
source = undefined;
}
});
-QUnit.test('can be instantiated manually', function() {
- var stream = new KeyStream(source, 'foo');
- equal(stream.value(), "zlurp");
+QUnit.test("can be instantiated manually", function() {
+ var nameStream = new KeyStream(source, 'name');
+ equal(nameStream.value(), "mmun", "Stream value is correct");
+});
+
+QUnit.test("can be instantiated via `Stream.prototype.get`", function() {
+ var nameStream = source.get('name');
+ equal(nameStream.value(), "mmun", "Stream value is correct");
+});
+
+QUnit.test("is notified when the observed object's property is mutated", function() {
+ var nameStream = source.get('name');
+ nameStream.subscribe(incrementCount);
+
+ equal(count, 0, "Subscribers called correct number of times");
+
+ nameStream.value(); // Prime the stream to notify subscribers
+ set(object, 'name', "wycats");
+
+ equal(count, 1, "Subscribers called correct number of times");
+ equal(nameStream.value(), "wycats", "Stream value is correct");
+});
+
+QUnit.test("is notified when the source stream's value changes to a new object", function() {
+ var nameStream = source.get('name');
+ nameStream.subscribe(incrementCount);
+
+ equal(count, 0, "Subscribers called correct number of times");
+
+ nameStream.value(); // Prime the stream to notify subscribers
+ source.setValue({ name: "wycats" });
+
+ equal(count, 1, "Subscribers called correct number of times");
+ equal(nameStream.value(), "wycats", "Stream value is correct");
+});
+
+QUnit.test("is notified when the source stream's value changes to the same object", function() {
+ var nameStream = source.get('name');
+ nameStream.subscribe(incrementCount);
+
+ equal(count, 0, "Subscribers called correct number of times");
+
+ nameStream.value(); // Prime the stream to notify subscribers
+ source.setValue(object);
+
+ equal(count, 1, "Subscribers called correct number of times");
+ equal(nameStream.value(), "mmun", "Stream value is correct");
});
-QUnit.test('can be instantiated via `Stream.prototype.get`', function() {
- var stream = source.get('foo');
- equal(stream.value(), "zlurp");
+QUnit.test("is notified when setSource is called with a new stream whose value is a new object", function() {
+ var nameStream = source.get('name');
+ nameStream.subscribe(incrementCount);
+
+ equal(count, 0, "Subscribers called correct number of times");
+
+ nameStream.value(); // Prime the stream to notify subscribers
+ nameStream.setSource(new Stream(function() {
+ return { name: "wycats" };
+ }));
+
+ equal(count, 1, "Subscribers called correct number of times");
+ equal(nameStream.value(), "wycats", "Stream value is correct");
+});
+
+QUnit.test("is notified when setSource is called with a new stream whose value is the same object", function() {
+ var nameStream = source.get('name');
+ nameStream.subscribe(incrementCount);
+
+ equal(count, 0, "Subscribers called correct number of times");
+
+ nameStream.value(); // Prime the stream to notify subscribers
+ nameStream.setSource(new Stream(function() {
+ return object;
+ }));
+
+ equal(count, 1, "Subscribers called correct number of times");
+ equal(nameStream.value(), "mmun", "Stream value is correct");
}); | false |
Other | emberjs | ember.js | ee865c24317d2f48b4ae8fa0d01a9c476801d5dd.json | Remove rebase error | packages/ember-htmlbars/lib/main.js | @@ -13,7 +13,6 @@ import makeBoundHelper from "ember-htmlbars/system/make_bound_helper";
import {
registerHelper
} from "ember-htmlbars/helpers";
-import viewHelper from "ember-htmlbars/helpers/view";
import {
ifHelper,
unlessHelper
@@ -30,7 +29,6 @@ import "ember-htmlbars/system/bootstrap";
// Ember.Handlebars global if htmlbars is enabled
import "ember-htmlbars/compat";
-registerHelper('@view', viewHelper);
registerHelper('if', ifHelper);
registerHelper('unless', unlessHelper);
registerHelper('with', withHelper); | false |
Other | emberjs | ember.js | 180856b5b6836f5cf95862ba02272722b064fc49.json | Add an #each test | packages/ember-htmlbars/tests/helpers/each_test.js | @@ -1001,6 +1001,34 @@ function testEachWithItem(moduleName, useBlockParams) {
equal(view.$().text(), "controller:people - controller:Steve Holt of Yapp - controller:people - controller:Annabelle of Yapp - ");
});
+
+ QUnit.test("locals in stable loops update when the list is updated", function() {
+ expect(3);
+
+ var list = [{ key: "adam", name: "Adam" }, { key: "steve", name: "Steve" }];
+ view = EmberView.create({
+ queries: list,
+ template: templateFor('{{#each view.queries key="key" as |query|}}{{query.name}}{{/each}}', true)
+ });
+ runAppend(view);
+ equal(view.$().text(), "AdamSteve");
+
+ run(function() {
+ list.unshift({ key: "bob", name: "Bob" });
+ view.set('queries', list);
+ view.notifyPropertyChange('queries');
+ });
+
+ equal(view.$().text(), "BobAdamSteve");
+
+ run(function() {
+ view.set('queries', [{ key: 'bob', name: "Bob" }, { key: 'steve', name: "Steve" }]);
+ view.notifyPropertyChange('queries');
+ });
+
+ equal(view.$().text(), "BobSteve");
+ });
+
if (!useBlockParams) {
QUnit.test("{{each}} without arguments [DEPRECATED]", function() {
expect(2); | false |
Other | emberjs | ember.js | c4bccc80450462cbf6c03f7a93ebe218ad72aee2.json | Utilize better host hooks in HTMLBars
This also clarifies the responsibilities of ShadowRoot, extracting any
notion of “components” into the parent ComponentNode and outlet keyword.
Lastly, this commit greatly cleans up the passing of scope into shadow
roots. In particular, the “hack” of using symbols to thread state
through via `self` has been eliminated. Instead, we implement
`createShadowScope()` and pass options to it. | packages/ember-htmlbars/lib/env.js | @@ -9,15 +9,14 @@ 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 createShadowScope from "ember-htmlbars/hooks/create-shadow-scope";
import bindSelf from "ember-htmlbars/hooks/bind-self";
import bindLocal from "ember-htmlbars/hooks/bind-local";
import getRoot from "ember-htmlbars/hooks/get-root";
import getChild from "ember-htmlbars/hooks/get-child";
import getValue from "ember-htmlbars/hooks/get-value";
import cleanup from "ember-htmlbars/hooks/cleanup";
-import content from "ember-htmlbars/hooks/content";
-import inline from "ember-htmlbars/hooks/inline";
-import block from "ember-htmlbars/hooks/block";
+import classify from "ember-htmlbars/hooks/classify";
import component from "ember-htmlbars/hooks/component";
import helpers from "ember-htmlbars/helpers";
@@ -27,6 +26,7 @@ var emberHooks = merge({}, hooks);
merge(emberHooks, {
linkRenderNode: linkRenderNode,
createFreshScope: createFreshScope,
+ createShadowScope: createShadowScope,
bindSelf: bindSelf,
bindLocal: bindLocal,
getRoot: getRoot,
@@ -35,9 +35,7 @@ merge(emberHooks, {
subexpr: subexpr,
concat: concat,
cleanup: cleanup,
- content: content,
- inline: inline,
- block: block,
+ classify: classify,
component: component
});
| true |
Other | emberjs | ember.js | c4bccc80450462cbf6c03f7a93ebe218ad72aee2.json | Utilize better host hooks in HTMLBars
This also clarifies the responsibilities of ShadowRoot, extracting any
notion of “components” into the parent ComponentNode and outlet keyword.
Lastly, this commit greatly cleans up the passing of scope into shadow
roots. In particular, the “hack” of using symbols to thread state
through via `self` has been eliminated. Instead, we implement
`createShadowScope()` and pass options to it. | packages/ember-htmlbars/lib/helpers/each.js | @@ -1,10 +1,14 @@
import { guidFor } from "ember-metal/utils";
+import { get } from "ember-metal/property_get";
export default function eachHelper(params, hash, blocks) {
var list = params[0];
+ var keyPath = hash.key;
for (var i=0, l=list.length; i<l; i++) {
var item = list[i];
- this.yieldItem(guidFor(item), [item, i]);
+ var key = keyPath ? get(item, keyPath) : guidFor(item);
+
+ this.yieldItem(key, [item, i]);
}
} | true |
Other | emberjs | ember.js | c4bccc80450462cbf6c03f7a93ebe218ad72aee2.json | Utilize better host hooks in HTMLBars
This also clarifies the responsibilities of ShadowRoot, extracting any
notion of “components” into the parent ComponentNode and outlet keyword.
Lastly, this commit greatly cleans up the passing of scope into shadow
roots. In particular, the “hack” of using symbols to thread state
through via `self` has been eliminated. Instead, we implement
`createShadowScope()` and pass options to it. | packages/ember-htmlbars/lib/hooks/bind-self.js | @@ -5,30 +5,25 @@
import SimpleStream from "ember-metal/streams/simple";
import { readHash } from "ember-metal/streams/utils";
-import { selfSymbol, componentSymbol } from "ember-htmlbars/system/symbols";
import { get } from "ember-metal/property_get";
import subscribe from "ember-htmlbars/utils/subscribe";
export default function bindSelf(scope, self) {
- var innerSelf = self[selfSymbol];
- var component = self[componentSymbol];
+ Ember.assert("BUG: scope.attrs and self.isView should not both be true", !(scope.attrs && self.isView));
- if (component) {
- scope.component = component;
- scope.view = component;
- updateScope(scope.locals, 'view', component, component.renderNode);
- updateScope(scope, 'attrs', readHash(innerSelf.attrs), component.renderNode);
- }
-
- self = innerSelf || self;
-
- if (self.isView) {
+ if (scope.attrs) {
+ updateScope(scope, 'attrsStream', readHash(scope.attrs), scope.renderNode);
+ updateScope(scope.locals, 'view', scope.view, null);
+ } else if (self.isView) {
scope.view = self;
updateScope(scope.locals, 'view', self, null);
updateScope(scope, 'self', get(self, 'context'), null);
- } else {
- updateScope(scope, 'self', self, null);
+ return;
+ } else if (scope.view) {
+ updateScope(scope.locals, 'view', scope.view, null);
}
+
+ updateScope(scope, 'self', self, null);
}
function updateScope(scope, key, newValue, renderNode) { | true |
Other | emberjs | ember.js | c4bccc80450462cbf6c03f7a93ebe218ad72aee2.json | Utilize better host hooks in HTMLBars
This also clarifies the responsibilities of ShadowRoot, extracting any
notion of “components” into the parent ComponentNode and outlet keyword.
Lastly, this commit greatly cleans up the passing of scope into shadow
roots. In particular, the “hack” of using symbols to thread state
through via `self` has been eliminated. Instead, we implement
`createShadowScope()` and pass options to it. | packages/ember-htmlbars/lib/hooks/block.js | @@ -1,10 +0,0 @@
-import { hooks as htmlbarsHooks } from "htmlbars-runtime";
-import isComponent from "ember-htmlbars/utils/is-component";
-
-export default function block(morph, env, scope, path, params, hash, template, inverse, visitor) {
- if (isComponent(env, scope, path)) {
- return env.hooks.component(morph, env, scope, path, hash, template, inverse, visitor);
- }
-
- return htmlbarsHooks.block(morph, env, scope, path, params, hash, template, inverse, visitor);
-} | true |
Other | emberjs | ember.js | c4bccc80450462cbf6c03f7a93ebe218ad72aee2.json | Utilize better host hooks in HTMLBars
This also clarifies the responsibilities of ShadowRoot, extracting any
notion of “components” into the parent ComponentNode and outlet keyword.
Lastly, this commit greatly cleans up the passing of scope into shadow
roots. In particular, the “hack” of using symbols to thread state
through via `self` has been eliminated. Instead, we implement
`createShadowScope()` and pass options to it. | packages/ember-htmlbars/lib/hooks/classify.js | @@ -0,0 +1,14 @@
+/**
+@module ember
+@submodule ember-htmlbars
+*/
+
+import isComponent from "ember-htmlbars/utils/is-component";
+
+export default function classify(env, scope, path) {
+ if (isComponent(env, scope, path)) {
+ return 'component';
+ }
+
+ return null;
+} | true |
Other | emberjs | ember.js | c4bccc80450462cbf6c03f7a93ebe218ad72aee2.json | Utilize better host hooks in HTMLBars
This also clarifies the responsibilities of ShadowRoot, extracting any
notion of “components” into the parent ComponentNode and outlet keyword.
Lastly, this commit greatly cleans up the passing of scope into shadow
roots. In particular, the “hack” of using symbols to thread state
through via `self` has been eliminated. Instead, we implement
`createShadowScope()` and pass options to it. | packages/ember-htmlbars/lib/hooks/content.js | @@ -1,10 +0,0 @@
-import { hooks as htmlbarsHooks } from "htmlbars-runtime";
-import isComponent from "ember-htmlbars/utils/is-component";
-
-export default function content(morph, env, scope, path, visitor) {
- if (isComponent(env, scope, path)) {
- return env.hooks.component(morph, env, scope, path, {}, null, null, visitor);
- }
-
- return htmlbarsHooks.content(morph, env, scope, path, visitor);
-} | true |
Other | emberjs | ember.js | c4bccc80450462cbf6c03f7a93ebe218ad72aee2.json | Utilize better host hooks in HTMLBars
This also clarifies the responsibilities of ShadowRoot, extracting any
notion of “components” into the parent ComponentNode and outlet keyword.
Lastly, this commit greatly cleans up the passing of scope into shadow
roots. In particular, the “hack” of using symbols to thread state
through via `self` has been eliminated. Instead, we implement
`createShadowScope()` and pass options to it. | packages/ember-htmlbars/lib/hooks/create-shadow-scope.js | @@ -0,0 +1,24 @@
+/**
+@module ember
+@submodule ember-htmlbars
+*/
+
+export default function createShadowScope(env, parentScope, options) {
+ var shadowScope = env.hooks.createFreshScope();
+
+ if (options.view) {
+ shadowScope.renderNode = options.renderNode;
+ shadowScope.view = options.view;
+ } else if (parentScope) {
+ shadowScope.view = parentScope.view;
+ shadowScope.locals.view = parentScope.locals.view;
+ }
+
+ if (options.view && options.attrs) {
+ shadowScope.component = options.view;
+ }
+
+ shadowScope.attrs = options.attrs;
+
+ return shadowScope;
+} | true |
Other | emberjs | ember.js | c4bccc80450462cbf6c03f7a93ebe218ad72aee2.json | Utilize better host hooks in HTMLBars
This also clarifies the responsibilities of ShadowRoot, extracting any
notion of “components” into the parent ComponentNode and outlet keyword.
Lastly, this commit greatly cleans up the passing of scope into shadow
roots. In particular, the “hack” of using symbols to thread state
through via `self` has been eliminated. Instead, we implement
`createShadowScope()` and pass options to it. | packages/ember-htmlbars/lib/hooks/get-root.js | @@ -21,14 +21,13 @@ export default function getRoot(scope, key) {
}
function getKey(scope, key) {
- if (key === 'attrs' && scope.attrs) {
- return scope.attrs;
+ if (key === 'attrs' && scope.attrsStream) {
+ return scope.attrsStream;
}
- var component = scope.component;
var self = scope.self;
- if (!component) {
+ if (!scope.attrsStream) {
return self.getKey(key);
}
@@ -37,18 +36,20 @@ function getKey(scope, key) {
var stream = new Stream(function() {
var view = read(scope.locals.view);
- var attrs = read(scope.attrs);
+ var attrs = read(scope.attrsStream);
if (key in attrs) {
Ember.deprecate("You accessed the `" + key + "` attribute directly. Please use `attrs." + key + "` instead.");
return read(attrs[key]);
}
- return get(view[key]);
+ if (typeof view === 'object' && view !== null) {
+ return get(view, key);
+ }
});
stream.addDependency(scope.locals.view);
- stream.addDependency(scope.attrs);
+ stream.addDependency(scope.attrsStream);
return stream;
} | true |
Other | emberjs | ember.js | c4bccc80450462cbf6c03f7a93ebe218ad72aee2.json | Utilize better host hooks in HTMLBars
This also clarifies the responsibilities of ShadowRoot, extracting any
notion of “components” into the parent ComponentNode and outlet keyword.
Lastly, this commit greatly cleans up the passing of scope into shadow
roots. In particular, the “hack” of using symbols to thread state
through via `self` has been eliminated. Instead, we implement
`createShadowScope()` and pass options to it. | packages/ember-htmlbars/lib/hooks/inline.js | @@ -1,10 +0,0 @@
-import { hooks as htmlbarsHooks } from "htmlbars-runtime";
-import isComponent from "ember-htmlbars/utils/is-component";
-
-export default function inline(morph, env, scope, path, params, hash, visitor) {
- if (isComponent(env, scope, path)) {
- return env.hooks.component(morph, env, scope, path, hash, null, visitor);
- }
-
- return htmlbarsHooks.inline(morph, env, scope, path, params, hash, visitor);
-} | true |
Other | emberjs | ember.js | c4bccc80450462cbf6c03f7a93ebe218ad72aee2.json | Utilize better host hooks in HTMLBars
This also clarifies the responsibilities of ShadowRoot, extracting any
notion of “components” into the parent ComponentNode and outlet keyword.
Lastly, this commit greatly cleans up the passing of scope into shadow
roots. In particular, the “hack” of using symbols to thread state
through via `self` has been eliminated. Instead, we implement
`createShadowScope()` and pass options to it. | packages/ember-htmlbars/lib/keywords/outlet.js | @@ -39,7 +39,11 @@ export default {
},
rerender: function(morph, env, scope, params, hash, template, inverse, visitor) {
- return morph.state.shadowRoot.rerender(env);
+ var newEnv = env;
+ if (morph.state.view) {
+ newEnv = merge({}, env);
+ newEnv.view = morph.state.view;
+ }
},
render: function(morph, env, scope, params, hash, template, inverse, visitor) {
@@ -58,8 +62,9 @@ export default {
}
var layoutMorph = layoutMorphFor(env, view, morph);
- state.shadowRoot = new ShadowRoot(layoutMorph, view, toRender.template, null, null);
- state.shadowRoot.render(env, toRender.controller || {}, visitor);
+ var options = { renderNode: view && view.renderNode, view: view };
+ state.shadowRoot = new ShadowRoot(layoutMorph, toRender.template, null, null);
+ state.shadowRoot.render(env, toRender.controller || {}, options, visitor);
// TODO: Do we need to copy lastResult?
} | true |
Other | emberjs | ember.js | c4bccc80450462cbf6c03f7a93ebe218ad72aee2.json | Utilize better host hooks in HTMLBars
This also clarifies the responsibilities of ShadowRoot, extracting any
notion of “components” into the parent ComponentNode and outlet keyword.
Lastly, this commit greatly cleans up the passing of scope into shadow
roots. In particular, the “hack” of using symbols to thread state
through via `self` has been eliminated. Instead, we implement
`createShadowScope()` and pass options to it. | packages/ember-htmlbars/lib/keywords/unbound.js | @@ -8,14 +8,14 @@ export default function unbound(morph, env, scope, originalParams, hash, templat
// the first param instead of (incorrectly) trying to read from it. If this was a call
// to `{{unbound foo.bar}}`, then we pass along the original stream to `hooks.range`.
var params = originalParams.slice();
- var path = params.shift();
+ var valueStream = params.shift();
if (params.length === 0) {
- env.hooks.range(morph, env, scope, path);
+ env.hooks.range(morph, env, scope, null, valueStream);
} else if (template === null) {
- env.hooks.inline(morph, env, scope, path.key, params, hash);
+ env.hooks.inline(morph, env, scope, valueStream.key, params, hash);
} else {
- env.hooks.block(morph, env, scope, path.key, params, hash, template, inverse);
+ env.hooks.block(morph, env, scope, valueStream.key, params, hash, template, inverse);
}
return true; | true |
Other | emberjs | ember.js | c4bccc80450462cbf6c03f7a93ebe218ad72aee2.json | Utilize better host hooks in HTMLBars
This also clarifies the responsibilities of ShadowRoot, extracting any
notion of “components” into the parent ComponentNode and outlet keyword.
Lastly, this commit greatly cleans up the passing of scope into shadow
roots. In particular, the “hack” of using symbols to thread state
through via `self` has been eliminated. Instead, we implement
`createShadowScope()` and pass options to it. | packages/ember-htmlbars/lib/system/component-node.js | @@ -1,4 +1,5 @@
import { get } from "ember-metal/property_get";
+import merge from "ember-metal/merge";
import Ember from "ember-metal/core";
import { validateChildMorphs } from "htmlbars-util";
import { readHash } from "ember-metal/streams/utils";
@@ -21,16 +22,15 @@ ComponentNode.create = function(renderNode, env, found, parentView, tagName, con
if (found.component) {
component = createComponent(found.component, parentView, renderNode);
component.renderNode = renderNode;
+ renderNode.state.component = component;
layoutMorph = component.renderer.contentMorphForView(component, renderNode);
layoutTemplate = get(component, 'layout') || get(component, 'template') || found.layout;
} else {
layoutMorph = renderNode;
layoutTemplate = found.layout;
}
- var shadowRoot = new ShadowRoot(layoutMorph, component, layoutTemplate,
- contentScope, contentTemplate);
-
+ var shadowRoot = new ShadowRoot(layoutMorph, layoutTemplate, contentScope, contentTemplate);
return new ComponentNode(component, shadowRoot);
};
@@ -43,7 +43,18 @@ ComponentNode.prototype.render = function(env, attrs, visitor, inDOM) {
var self = { attrs: attrs };
- this.shadowRoot.render(env, self, visitor);
+ var newEnv = env;
+ if (this.component) {
+ newEnv = merge({}, env);
+ newEnv.view = this.component;
+ }
+
+ var options = {
+ view: this.component,
+ renderNode: this.component && this.component.renderNode
+ };
+
+ this.shadowRoot.render(newEnv, self, options, visitor);
if (component) {
if (inDOM) {
@@ -56,25 +67,30 @@ ComponentNode.prototype.render = function(env, attrs, visitor, inDOM) {
};
ComponentNode.prototype.rerender = function(env, attrs, visitor) {
- env = this.shadowRoot.rerender(env);
+ var newEnv = env;
+ if (this.component) {
+ newEnv = merge({}, env);
+ newEnv.view = this.component;
+ }
+
var component = this.component;
if (component) {
var snapshot = readHash(attrs);
if (component.renderNode.state.shouldReceiveAttrs) {
- env.renderer.updateAttrs(component, snapshot);
+ newEnv.renderer.updateAttrs(component, snapshot);
component.renderNode.state.shouldReceiveAttrs = false;
}
// TODO: Trigger this on re-renders, even though the component will
// not (atm) have been dirtied
- env.renderer.willUpdate(component, snapshot);
+ newEnv.renderer.willUpdate(component, snapshot);
}
- validateChildMorphs(env, this.shadowRoot.layoutMorph, visitor);
+ validateChildMorphs(newEnv, this.shadowRoot.layoutMorph, visitor);
- return env;
+ return newEnv;
};
function lookupComponent(env, tagName) { | true |
Other | emberjs | ember.js | c4bccc80450462cbf6c03f7a93ebe218ad72aee2.json | Utilize better host hooks in HTMLBars
This also clarifies the responsibilities of ShadowRoot, extracting any
notion of “components” into the parent ComponentNode and outlet keyword.
Lastly, this commit greatly cleans up the passing of scope into shadow
roots. In particular, the “hack” of using symbols to thread state
through via `self` has been eliminated. Instead, we implement
`createShadowScope()` and pass options to it. | packages/ember-htmlbars/lib/system/shadow-root.js | @@ -1,58 +1,33 @@
-import merge from "ember-metal/merge";
-import { hooks as htmlbarsHooks } from "htmlbars-runtime";
+import { internal } from "htmlbars-runtime";
/** @private
A ShadowRoot represents a new root scope. However, it
is not a render tree root.
*/
-import { componentSymbol, selfSymbol } from "ember-htmlbars/system/symbols";
-
-function ShadowRoot(layoutMorph, component, layoutTemplate, contentScope, contentTemplate) {
- this.update(layoutMorph, component, layoutTemplate, contentScope, contentTemplate);
-}
-
-ShadowRoot.prototype.update = function(layoutMorph, component, layoutTemplate, contentScope, contentTemplate) {
+function ShadowRoot(layoutMorph, layoutTemplate, contentScope, contentTemplate) {
this.layoutMorph = layoutMorph;
this.layoutTemplate = layoutTemplate;
- this.hostComponent = component;
this.contentScope = contentScope;
this.contentTemplate = contentTemplate;
-};
+}
-ShadowRoot.prototype.render = function(env, self, visitor) {
+ShadowRoot.prototype.render = function(env, self, shadowOptions, visitor) {
if (!this.layoutTemplate && !this.contentTemplate) { return; }
- var passedSelf = {};
- passedSelf[selfSymbol] = self;
- passedSelf[componentSymbol] = this.hostComponent || true;
-
- var hash = { self: passedSelf, layout: this.layoutTemplate };
-
- var newEnv = env;
- if (this.hostComponent) {
- newEnv = merge({}, env);
- newEnv.view = this.hostComponent;
- }
-
- // Invoke the `@view` helper. Tell it to render the layout template into the
- // layout morph. When the layout template `{{yield}}`s, it should render the
- // contentTemplate with the contentScope.
- htmlbarsHooks.block(this.layoutMorph, newEnv, this.contentScope, '@view',
- [], hash, this.contentTemplate || null, null, visitor);
-};
-
-ShadowRoot.prototype.rerender = function(env) {
- if (!this.layoutTemplate && !this.contentTemplate) { return; }
+ shadowOptions.attrs = self.attrs;
- var newEnv = env;
- if (this.hostComponent) {
- newEnv = merge({}, env);
- newEnv.view = this.hostComponent;
- }
+ var shadowRoot = this;
- return newEnv;
+ internal.hostBlock(this.layoutMorph, env, this.contentScope, this.contentTemplate || null, null, shadowOptions, visitor, function(options) {
+ var template = options.templates.template;
+ if (shadowRoot.layoutTemplate) {
+ template.yieldIn(shadowRoot.layoutTemplate, self);
+ } else if (template.yield) {
+ template.yield();
+ }
+ });
};
ShadowRoot.prototype.isStable = function(layout, template) { | true |
Other | emberjs | ember.js | c4bccc80450462cbf6c03f7a93ebe218ad72aee2.json | Utilize better host hooks in HTMLBars
This also clarifies the responsibilities of ShadowRoot, extracting any
notion of “components” into the parent ComponentNode and outlet keyword.
Lastly, this commit greatly cleans up the passing of scope into shadow
roots. In particular, the “hack” of using symbols to thread state
through via `self` has been eliminated. Instead, we implement
`createShadowScope()` and pass options to it. | packages/ember-htmlbars/lib/system/symbols.js | @@ -1,6 +0,0 @@
-import { symbol } from "ember-metal/utils";
-
-export var selfSymbol = symbol("self");
-export var componentClassSymbol = symbol("componentClass");
-export var componentLayoutSymbol = symbol("componentLayout");
-export var componentSymbol = symbol("component"); | true |
Other | emberjs | ember.js | c4bccc80450462cbf6c03f7a93ebe218ad72aee2.json | Utilize better host hooks in HTMLBars
This also clarifies the responsibilities of ShadowRoot, extracting any
notion of “components” into the parent ComponentNode and outlet keyword.
Lastly, this commit greatly cleans up the passing of scope into shadow
roots. In particular, the “hack” of using symbols to thread state
through via `self` has been eliminated. Instead, we implement
`createShadowScope()` and pass options to it. | packages/ember-views/lib/views/states/has_element.js | @@ -9,7 +9,7 @@ import jQuery from "ember-views/system/jquery";
*/
import { get } from "ember-metal/property_get";
-import { visitChildren } from "htmlbars-runtime";
+import { internal } from "htmlbars-runtime";
var hasElement = create(_default);
@@ -32,7 +32,7 @@ merge(hasElement, {
var renderNode = view.renderNode;
renderNode.isDirty = true;
- visitChildren(renderNode.childNodes, function(node) {
+ internal.visitChildren(renderNode.childNodes, function(node) {
node.isDirty = true;
});
renderNode.ownerNode.state.view.scheduleRevalidate(); | true |
Other | emberjs | ember.js | b3d529e855f30298776d54ff5069482871c73da2.json | Remove Safari from Sauce Labs runs.
It has provent to be unstable. Specifically, the `unsafe:` protocol
prefixes that we add for JS attribute sanitization cause the tests to
restart from the beginning (not really sure why). You can see this in
action in the following video:
https://assets.saucelabs.com/jobs/8e88992e101541a1b441139894233203/video_8e88992e101541a1b441139894233203.flv | testem.json | @@ -41,7 +41,6 @@
"launch_in_ci": [
"SL_Chrome_Current",
"SL_IE_11",
- "SL_IE_10",
- "SL_Safari_Current"
+ "SL_IE_10"
]
} | false |
Other | emberjs | ember.js | d596adc5669be4872f291be5dbde857a2f256d1a.json | Use testem directly for sauce tests.
Avoids a double build. | bin/run-sauce-tests.js | @@ -38,8 +38,14 @@ RSVP.resolve()
return run('./node_modules/.bin/ember', [ 'start-sauce-connect' ]);
})
.then(function() {
- return run('./node_modules/.bin/ember', [ 'test' ]);
+ // calling testem directly here instead of `ember test` so that
+ // we do not have to do a double build (by the time this is run
+ // we have already ran `ember build`).
+ return run('./node_modules/.bin/testem', [ 'ci' ]);
})
- .catch(function(error) {
+ .finally(function() {
+ return run('./node_modules/.bin/ember', [ 'stop-sauce-connect' ]);
+ })
+ .catch(function() {
process.exit(1);
}); | true |
Other | emberjs | ember.js | d596adc5669be4872f291be5dbde857a2f256d1a.json | Use testem directly for sauce tests.
Avoids a double build. | package.json | @@ -29,6 +29,7 @@
"qunitjs": "^1.16.0",
"route-recognizer": "0.1.5",
"rsvp": "~3.0.6",
- "simple-dom": "^0.1.1"
+ "simple-dom": "^0.1.1",
+ "testem": "^0.7.6"
}
} | true |
Other | emberjs | ember.js | d596adc5669be4872f291be5dbde857a2f256d1a.json | Use testem directly for sauce tests.
Avoids a double build. | testem.json | @@ -1,8 +1,8 @@
{
"framework": "qunit",
- "test_page": "tests/index.html?hidepassed",
+ "test_page": "dist/tests/index.html?hidepassed",
"timeout": 540,
- "parallel": 2,
+ "parallel": 4,
"launchers": {
"SL_Chrome_Current": {
"command": "./node_modules/.bin/ember-cli-sauce -b chrome --no-ct -u <url>",
@@ -39,6 +39,8 @@
},
"launch_in_dev": [],
"launch_in_ci": [
- "SL_Chrome_Current"
+ "SL_Chrome_Current",
+ "SL_IE_11",
+ "SL_IE_10"
]
} | true |
Other | emberjs | ember.js | bd37fe7e6c9f19bca43e75da78cc85fc09b25dda.json | Add cross browser tests. | .travis.yml | @@ -10,6 +10,11 @@ cache:
- node_modules
- bower_components
+before_install:
+ - "npm config set spin false"
+ - "npm install -g npm@^2"
+ - "npm --version"
+
install:
- "npm install"
@@ -19,8 +24,13 @@ after_success:
script:
- npm test
+after_script:
+ - ember stop-sauce-connect
+
env:
global:
+ - SAUCE_USERNAME=ember-ci
+ - SAUCE_ACCESS_KEY=b5cff982-069f-4a0d-ac34-b77e57c2e295
- DISABLE_SOURCE_MAPS=true
- BROCCOLI_ENV=production
- S3_BUILD_CACHE_BUCKET=emberjs-build-cache
@@ -43,3 +53,4 @@ env:
- TEST_SUITE=old-jquery
- TEST_SUITE=extend-prototypes
- TEST_SUITE=node EMBER_ENV=production
+ - TEST_SUITE=sauce | true |
Other | emberjs | ember.js | bd37fe7e6c9f19bca43e75da78cc85fc09b25dda.json | Add cross browser tests. | bin/run-sauce-tests.js | @@ -0,0 +1,49 @@
+#!/usr/bin/env node
+
+var RSVP = require('rsvp');
+var spawn = require('child_process').spawn;
+
+function run(command, _args) {
+ var args = _args || [];
+
+ return new RSVP.Promise(function(resolve, reject) {
+ console.log('Running: ' + command + ' ' + args.join(' '));
+
+ var child = spawn(command, args);
+
+ child.stdout.on('data', function (data) {
+ console.log(data.toString());
+ });
+
+ child.stderr.on('data', function (data) {
+ console.error(data.toString());
+ });
+
+ child.on('error', function(err) {
+ reject(err);
+ });
+
+ child.on('exit', function(code) {
+ if (code === 0) {
+ resolve();
+ } else {
+ reject(code);
+ }
+ });
+ });
+}
+
+RSVP.resolve()
+ .then(function() {
+ return run('./node_modules/.bin/ember', [ 'start-sauce-connect' ]);
+ })
+ .then(function() {
+ return run('./node_modules/.bin/testem', [ 'ci', '--debug', '--bail_on_uncaught_error' ]);
+ })
+ .catch(function(error) {
+ var fs = require('fs');
+ console.log(fs.readFileSync('testem.log', { encoding: 'utf8' }));
+
+ console.error(error);
+ process.exit(1);
+ }); | true |
Other | emberjs | ember.js | bd37fe7e6c9f19bca43e75da78cc85fc09b25dda.json | Add cross browser tests. | bin/run-tests.js | @@ -138,6 +138,9 @@ switch (process.env.TEST_SUITE) {
case 'node':
require('./run-node-tests');
return;
+ case 'sauce':
+ require('./run-sauce-tests');
+ return;
default:
generateEachPackageTests();
} | true |
Other | emberjs | ember.js | bd37fe7e6c9f19bca43e75da78cc85fc09b25dda.json | Add cross browser tests. | package.json | @@ -16,6 +16,7 @@
"chalk": "^0.5.1",
"ember-cli": "^0.2.0",
"ember-cli-dependency-checker": "0.0.7",
+ "ember-cli-sauce": "^1.0.0",
"ember-cli-yuidoc": "^0.4.0",
"ember-publisher": "0.0.7",
"emberjs-build": "0.0.43",
@@ -28,6 +29,8 @@
"qunitjs": "^1.16.0",
"route-recognizer": "0.1.5",
"rsvp": "~3.0.6",
- "simple-dom": "^0.1.1"
+ "saucie": "^0.1.3",
+ "simple-dom": "^0.1.1",
+ "testem": "^0.7.6"
}
} | true |
Other | emberjs | ember.js | bd37fe7e6c9f19bca43e75da78cc85fc09b25dda.json | Add cross browser tests. | testem.json | @@ -0,0 +1,48 @@
+{
+ "framework": "qunit",
+ "test_page": "dist/tests/index.html?hidepassed",
+ "timeout": 60,
+ "parallel": 2,
+ "launchers":
+ {
+ "SL_Chrome_Current": {
+ "command": "./node_modules/.bin/saucie -tg ember -b chrome -v 39 --no-ct -u <url>",
+ "protocol": "tap",
+ "hide_stdout": false
+ },
+ "SL_Firefox_Current": {
+ "command": "./node_modules/.bin/saucie -tg ember -b firefox -v 34 --no-ct -u <url>",
+ "protocol": "tap"
+ },
+ "SL_Safari_Current": {
+ "command": "./node_modules/.bin/saucie -tg ember -b safari -v 8 --no-ct -u <url>",
+ "protocol": "tap"
+ },
+ "SL_Safari_Last": {
+ "command": "./node_modules/.bin/saucie -tg ember -b safari -v 7 --no-ct -u <url>",
+ "protocol": "tap"
+ },
+ "SL_IE_11": {
+ "command": "./node_modules/.bin/saucie -tg ember -b 'internet explorer' -v 11 --no-ct -u <url>",
+ "protocol": "tap"
+ },
+ "SL_IE_10": {
+ "command": "./node_modules/.bin/saucie -tg ember -b 'internet explorer' -v 10 --no-ct -u <url>",
+ "protocol": "tap"
+ },
+ "SL_IE_9": {
+ "command": "./node_modules/.bin/saucie -tg ember -b 'internet explorer' -v 9 --no-ct -u <url>",
+ "protocol": "tap"
+ },
+ "SL_IE_8": {
+ "command": "./node_modules/.bin/saucie -tg ember -b 'internet explorer' -v 8 --no-ct -u <url>",
+ "protocol": "tap"
+ }
+ }
+ ,
+ "launch_in_dev": [ ],
+ "launch_in_ci": [
+ "SL_Chrome_Current"
+ ]
+}
+ | true |
Other | emberjs | ember.js | bd37fe7e6c9f19bca43e75da78cc85fc09b25dda.json | Add cross browser tests. | tests/index.html | @@ -5,6 +5,7 @@
<title>Ember</title>
<link rel="stylesheet" href="../qunit/qunit.css">
<script src="../qunit/qunit.js"></script>
+ <script src="/testem.js"></script>
<script type="text/javascript">
window.loadScript = function(url) { | true |
Other | emberjs | ember.js | 9030e3f01d09bb8c54c18b89841cdab9c8e01477.json | Add livereload to test suite.
We will now optionally inject the livereload script if the `Live Reload`
checkbox is checked. | tests/index.html | @@ -116,6 +116,8 @@
QUnit.config.urlConfig.push({ id: 'enableoptionalfeatures', label: "Enable Opt Features"});
// Handle extending prototypes
QUnit.config.urlConfig.push({ id: 'extendprototypes', label: 'Extend Prototypes'});
+ // Enable/disable livereload
+ QUnit.config.urlConfig.push({ id: 'livereload', label: 'Live Reload'});
// Handle JSHint
QUnit.config.urlConfig.push('nojshint');
})();
@@ -138,6 +140,19 @@
if (!QUnit.urlParams.nojshint && moduleName.match(/[-_.]jshint$/)) { Ember.__loader.require(moduleName); }
}
</script>
+
+ <script>
+ if (QUnit.urlParams.livereload) {
+ (function() {
+ var src = (location.protocol || 'http:') + '//' + (location.hostname || 'localhost') + ':' + (parseInt(location.port, 10) + 31529) + '/livereload.js?snipver=1';
+ var script = document.createElement('script');
+ script.type = 'text/javascript';
+ script.src = src;
+ document.getElementsByTagName('head')[0].appendChild(script);
+ }());
+ }
+ </script>
+
</head>
<body>
<div id="qunit"></div> | false |
Other | emberjs | ember.js | 7303bd61ceba33ae403565520233d60bf04bafda.json | Add 1.11.0 changelog. | CHANGELOG.md | @@ -4,8 +4,38 @@
- [#3852](https://github.com/emberjs/ember.js/pull/3852) [BREAKING BUGFIX] Do not assume null Ember.get targets always refer to a global
-### 1.11.0-beta.1 (February 06, 2015)
-
+### 1.11.0 (March 28, 2015)
+
+- [#10736](https://github.com/emberjs/ember.js/pull/10736) [BUGFIX] Fix issue with Query Params when using `Ember.ObjectController` (regression from `ObjectController` deprecation).
+- [#10726](https://github.com/emberjs/ember.js/pull/10726) / [router.js#ed45bc](https://github.com/tildeio/router.js/commit/ed45bc5c5e055af0ab875ef2c52feda792ee23e4) [BUGFIX] Fix issue with nested `{{link-to}}` active and transition classes getting out of sync.
+- [#10709](https://github.com/emberjs/ember.js/pull/10709) [BUGFIX] Clear `src` attributes that are set to `null` or `undefined`.
+- [#10695](https://github.com/emberjs/ember.js/pull/10695) [SECURITY] Add `<base>` and `<embed>` to list of tags where `src` and `href` are sanitized.
+- [#10683](https://github.com/emberjs/ember.js/pull/10683) / [#10703](https://github.com/emberjs/ember.js/pull/10703) / [#10712](https://github.com/emberjs/ember.js/pull/10712) [BUGFIX] Fix regressions added during the `{{outlet}}` refactor.
+- [#10663](https://github.com/emberjs/ember.js/pull/10663) / [#10711](https://github.com/emberjs/ember.js/pull/10711) [SECURITY] Warn when using dynamic style attributes without a `SafeString` value. [See here](http://emberjs.com/deprecations/v1.x/#toc_warning-when-binding-style-attributes) for more details.
+- [#10463](https://github.com/emberjs/ember.js/pull/10463) [BUGFIX] Make async test helpers more robust. Fixes hanging test when elements are not found.
+- [#10631](https://github.com/emberjs/ember.js/pull/10631) Deprecate using `fooBinding` syntax (`{{some-thing nameBinding="model.name"}}`) in templates.
+- [#10627](https://github.com/emberjs/ember.js/pull/10627) [BUGFIX] Ensure specifying `class` as a sub-expression (`{{input value=foo class=(some-sub-expr)}}`) works properly.
+- [#10613](https://github.com/emberjs/ember.js/pull/10613) [BUGFIX] Ensure `{{view id=bar}}` sets `id` on the view.
+- [#10612](https://github.com/emberjs/ember.js/pull/10612) [BUGFIX] Ensure `Ember.inject.controller()` works for all Controller types.
+- [#10604](https://github.com/emberjs/ember.js/pull/10604) [BUGFIX] Fix regression on iOS 8 crashing on certain platforms.
+- [#10556](https://github.com/emberjs/ember.js/pull/10556) [BUGFIX] Deprecate `{{link-to}}` unwrapping a controllers model.
+- [#10528](https://github.com/emberjs/ember.js/pull/10528) [BUGFIX] Ensure custom Router can be passed to Ember.Application.
+- [#10530](https://github.com/emberjs/ember.js/pull/10530) [BUGFIX] Add assertion when calling `this.$()` in a tagless view/component.
+- [#10533](https://github.com/emberjs/ember.js/pull/10533) [BUGFIX] Do not allow manually specifying `application` resource in the `Router.map`.
+- [#10544](https://github.com/emberjs/ember.js/pull/10544) / [#10550](https://github.com/emberjs/ember.js/pull/10550) [BUGFIX] Ensure that `{{input}}` can be updated multiple times, and does not loose cursor position.
+- [#10553](https://github.com/emberjs/ember.js/pull/10553) [BUGFIX] Fix major regression in the non-block form of `{{link-to}}` that caused an application crash after a period of time.
+- [#10554](https://github.com/emberjs/ember.js/pull/10554) [BUGFIX] Remove access to `this` in HTMLBars helpers. To fix any usages of `this` in a helper, you can access the view from `env.data.view` instead.
+- [#10475](https://github.com/emberjs/ember.js/pull/10475) [BUGFIX] Ensure wrapped errors are logged properly.
+- [#10489](https://github.com/emberjs/ember.js/pull/10489) [BUGFIX] Fix an issue with bindings inside of a yielded template when the yield helper is nested inside of another view
+- [#10493](https://github.com/emberjs/ember.js/pull/10493) [BUGFIX] Fix nested simple bindings inside of nested yields within views.
+- [#10527](https://github.com/emberjs/ember.js/pull/10527) [BUGFIX] Ensure that Component context is not forced to parent context.
+- [#10525](https://github.com/emberjs/ember.js/pull/10525) [BUGFIX] Fix issue causing cursor position to be lost while entering into an `{{input}}` / `Ember.TextField`.
+- [#10372](https://github.com/emberjs/ember.js/pull/10372) / [#10431](https://github.com/emberjs/ember.js/pull/10431) / [#10439](https://github.com/emberjs/ember.js/pull/10439) / [#10442](https://github.com/emberjs/ember.js/pull/10442) Decouple route transition from view creation.
+- [#10436](https://github.com/emberjs/ember.js/pull/10436) [BUGFIX] Ensure `instrument.{subscribe,unsubscribe,reset}` aren’t accidentally clobbered.
+- [#10462](https://github.com/emberjs/ember.js/pull/10462) [BUGFIX] Fix incorrect export of `Ember.OutletView`.
+- [#10398](https://github.com/emberjs/ember.js/pull/10398) [BUGFIX] `undefined` and `null` values in bind-attr shoud remove attributes.
+- [#10413](https://github.com/emberjs/ember.js/pull/10413) Update to use inclusive `morph-range` (via HTMLBars v0.11.1).
+- [#10464](https://github.com/emberjs/ember.js/pull/10464) Add helpful assertion if templates are compiled with a different template compiler revision.
- [#10160](https://github.com/emberjs/ember.js/pull/10160) [FEATURE] Add index as an optional parameter to #each blocks [@tim-evans](https://github.com/tim-evans)
- [#10186](https://github.com/emberjs/ember.js/pull/10186) Port attributeBindings to AttrNode views [@mixonic](https://github.com/mixonic)
- [#10184](https://github.com/emberjs/ember.js/pull/10184) Initial support basic Node.js rendering. | false |
Other | emberjs | ember.js | f3aeaf7727eda467b30a5f338824db2fd7baf42a.json | Fix more recent JSCS failures. | packages/ember-views/lib/views/view.js | @@ -667,6 +667,7 @@ var EMPTY_ARRAY = [];
@namespace Ember
@extends Ember.CoreView
*/
+// jscs:disable validateIndentation
var View = CoreView.extend(
ViewStreamSupport,
ViewKeywordSupport,
@@ -1435,6 +1436,7 @@ var View = CoreView.extend(
return scheduledFn;
}
});
+// jscs:enable validateIndentation
deprecateProperty(View.prototype, 'state', '_state');
deprecateProperty(View.prototype, 'states', '_states');
@@ -1457,14 +1459,14 @@ deprecateProperty(View.prototype, 'states', '_states');
on a destroyed view.
*/
- // in the destroyed state, everything is illegal
+// in the destroyed state, everything is illegal
- // before rendering has begun, all legal manipulations are noops.
+// before rendering has begun, all legal manipulations are noops.
- // inside the buffer, legal manipulations are done on the buffer
+// inside the buffer, legal manipulations are done on the buffer
- // once the view has been inserted into the DOM, legal manipulations
- // are done on the DOM element.
+// once the view has been inserted into the DOM, legal manipulations
+// are done on the DOM element.
var mutation = EmberObject.extend(Evented).create();
// TODO MOVE TO RENDERER HOOKS | true |
Other | emberjs | ember.js | f3aeaf7727eda467b30a5f338824db2fd7baf42a.json | Fix more recent JSCS failures. | packages/ember-views/tests/views/collection_test.js | @@ -608,10 +608,10 @@ QUnit.test("should render the emptyView if content array is empty and emptyView
Ember.lookup = {
App: {
EmptyView: View.extend({
- tagName: 'kbd',
- render(buf) {
- buf.push("THIS IS AN EMPTY VIEW");
- }
+ tagName: 'kbd',
+ render(buf) {
+ buf.push("THIS IS AN EMPTY VIEW");
+ }
})
}
}; | true |
Other | emberjs | ember.js | cfe40f8dd8012e7d51bb2061a539c2410c6f3ca1.json | Lock esperanto down to 0.6.17. | package.json | @@ -19,6 +19,7 @@
"ember-cli-yuidoc": "^0.4.0",
"ember-publisher": "0.0.7",
"emberjs-build": "0.0.43",
+ "esperanto": "0.6.17",
"express": "^4.5.0",
"github": "^0.2.3",
"glob": "~4.3.2", | false |
Other | emberjs | ember.js | c98aced52fcfceee6ea8aca7329b90a7f7a3ec92.json | Remove unused variables in custom JSCS rule. | lib/jscs-rules/require-spaces-after-closing-parenthesis-in-function-declaration.js | @@ -25,15 +25,8 @@ module.exports.prototype = {
check: function(file, errors) {
var beforeOpeningRoundBrace = this._beforeOpeningRoundBrace;
var beforeOpeningCurlyBrace = this._beforeOpeningCurlyBrace;
- var tokens = file.getTokens();
file.iterateNodesByType(['FunctionDeclaration'], function(node) {
- var nodeBeforeRoundBrace = node;
- // named function
- if (node.id) {
- nodeBeforeRoundBrace = node.id;
- }
-
var functionToken = file.getFirstNodeToken(node.id || node);
var nextToken = file.getNextToken(functionToken);
| false |
Other | emberjs | ember.js | 9acdd097555d566382f626bd2ee4f6ce9e2bc7fb.json | Add link to the guides in deprecation warning | packages/ember-metal/lib/computed.js | @@ -117,7 +117,9 @@ function ComputedProperty(config, opts) {
config.__ember_arity = config.length;
this._getter = config;
if (config.__ember_arity > 1) {
- Ember.deprecate("Using the same function as getter and setter is deprecated");
+ Ember.deprecate("Using the same function as getter and setter is deprecated.", false, {
+ url: "http://emberjs.com/deprecations/v1.x/#toc_deprecate-using-the-same-function-as-getter-and-setter-in-computed-properties"
+ });
this._setter = config;
}
} else { | false |
Other | emberjs | ember.js | 1b02939a7a095c883de55be9f4f09419b50c4a69.json | Exclude debug only tests in production builds. | packages/ember-views/tests/views/view/element_test.js | @@ -1,3 +1,5 @@
+/*globals EmberDev */
+
import { get } from "ember-metal/property_get";
import { set } from "ember-metal/property_set";
import run from "ember-metal/run_loop";
@@ -45,7 +47,7 @@ QUnit.test("returns element if you set the value", function() {
equal(get(view, 'element'), dom, 'now has set element');
});
-Ember.runInDebug(function() {
+if (EmberDev && !EmberDev.runningProdBuild) {
QUnit.test("should not allow the elementId to be changed after inserted", function() {
view = EmberView.create({
elementId: 'one'
@@ -61,5 +63,4 @@ Ember.runInDebug(function() {
equal(view.get('elementId'), 'one', 'elementId is still "one"');
});
-});
-
+} | false |
Other | emberjs | ember.js | 7003f2bd5f3827b01f97fd04c17c8ef77b429bf1.json | Update emberjs-build to 0.0.43.
Compare view:
https://github.com/emberjs/emberjs-build/compare/v0.0.39...v0.0.43
Major changes:
* Update JSCS to latest version
* Allow template compilation to use `Ember.deprecate`.
* Add `ember-metal` to `ember-template-compiler.js`
* Add `ember-debug` into `ember-template-compiler.js` | package.json | @@ -18,7 +18,7 @@
"ember-cli-dependency-checker": "0.0.7",
"ember-cli-yuidoc": "^0.4.0",
"ember-publisher": "0.0.7",
- "emberjs-build": "0.0.39",
+ "emberjs-build": "0.0.43",
"express": "^4.5.0",
"github": "^0.2.3",
"glob": "~4.3.2", | false |
Other | emberjs | ember.js | f3d645dccd9464a20fdb82d59b12ebded131596e.json | Use new cps (get/set) internally | packages/ember-metal/lib/computed.js | @@ -117,6 +117,7 @@ function ComputedProperty(config, opts) {
config.__ember_arity = config.length;
this._getter = config;
if (config.__ember_arity > 1) {
+ Ember.deprecate("Using the same function as getter and setter is deprecated");
this._setter = config;
}
} else { | true |
Other | emberjs | ember.js | f3d645dccd9464a20fdb82d59b12ebded131596e.json | Use new cps (get/set) internally | packages/ember-metal/lib/computed_macros.js | @@ -674,13 +674,16 @@ export function readOnly(dependentKey) {
@deprecated Use `Ember.computed.oneWay` or custom CP with default instead.
*/
export function defaultTo(defaultPath) {
- return computed(function(key, newValue, cachedValue) {
- Ember.deprecate('Usage of Ember.computed.defaultTo is deprecated, use `Ember.computed.oneWay` instead.');
-
- if (arguments.length === 1) {
+ return computed({
+ get: function(key) {
+ Ember.deprecate('Usage of Ember.computed.defaultTo is deprecated, use `Ember.computed.oneWay` instead.');
return get(this, defaultPath);
+ },
+
+ set: function(key, newValue, cachedValue) {
+ Ember.deprecate('Usage of Ember.computed.defaultTo is deprecated, use `Ember.computed.oneWay` instead.');
+ return newValue != null ? newValue : get(this, defaultPath);
}
- return newValue != null ? newValue : get(this, defaultPath);
});
}
@@ -698,14 +701,15 @@ export function defaultTo(defaultPath) {
@since 1.7.0
*/
export function deprecatingAlias(dependentKey) {
- return computed(dependentKey, function(key, value) {
- Ember.deprecate(`Usage of \`${key}\` is deprecated, use \`${dependentKey}\` instead.`);
-
- if (arguments.length > 1) {
+ return computed(dependentKey, {
+ get: function(key) {
+ Ember.deprecate(`Usage of \`${key}\` is deprecated, use \`${dependentKey}\` instead.`);
+ return get(this, dependentKey);
+ },
+ set: function(key, value) {
+ Ember.deprecate(`Usage of \`${key}\` is deprecated, use \`${dependentKey}\` instead.`);
set(this, dependentKey, value);
return value;
- } else {
- return get(this, dependentKey);
}
});
} | true |
Other | emberjs | ember.js | f3d645dccd9464a20fdb82d59b12ebded131596e.json | Use new cps (get/set) internally | packages/ember-metal/tests/binding/sync_test.js | @@ -17,14 +17,15 @@ testBoth("bindings should not sync twice in a single run loop", function(get, se
run(function() {
a = {};
- defineProperty(a, 'foo', computed(function(key, value) {
- if (arguments.length === 2) {
+ defineProperty(a, 'foo', computed({
+ get: function(key) {
+ getCalled++;
+ return setValue;
+ },
+ set: function(key, value) {
setCalled++;
setValue = value;
return value;
- } else {
- getCalled++;
- return setValue;
}
}).volatile());
| true |
Other | emberjs | ember.js | f3d645dccd9464a20fdb82d59b12ebded131596e.json | Use new cps (get/set) internally | packages/ember-metal/tests/computed_test.js | @@ -65,15 +65,15 @@ QUnit.test('defining computed property should invoke property on get', function(
});
QUnit.test('defining computed property should invoke property on set', function() {
-
var obj = {};
var count = 0;
- defineProperty(obj, 'foo', computed(function(key, value) {
- if (value !== undefined) {
+ defineProperty(obj, 'foo', computed({
+ get: function(key) { return this['__'+key]; },
+ set: function(key, value) {
count++;
this['__'+key] = 'computed '+value;
+ return this['__'+key];
}
- return this['__'+key];
}));
equal(set(obj, 'foo', 'bar'), 'bar', 'should return set value');
@@ -85,11 +85,14 @@ var objA, objB;
QUnit.module('computed should inherit through prototype', {
setup() {
objA = { __foo: 'FOO' };
- defineProperty(objA, 'foo', computed(function(key, value) {
- if (value !== undefined) {
+ defineProperty(objA, 'foo', computed({
+ get: function(key) {
+ return this['__'+key];
+ },
+ set: function(key, value) {
this['__'+key] = 'computed '+value;
+ return this['__'+key];
}
- return this['__'+key];
}));
objB = create(objA);
@@ -121,11 +124,14 @@ testBoth('using get() and set()', function(get, set) {
QUnit.module('redefining computed property to normal', {
setup() {
objA = { __foo: 'FOO' };
- defineProperty(objA, 'foo', computed(function(key, value) {
- if (value !== undefined) {
+ defineProperty(objA, 'foo', computed({
+ get: function(key) {
+ return this['__'+key];
+ },
+ set: function(key, value) {
this['__'+key] = 'computed '+value;
+ return this['__'+key];
}
- return this['__'+key];
}));
objB = create(objA);
@@ -157,20 +163,24 @@ testBoth('using get() and set()', function(get, set) {
QUnit.module('redefining computed property to another property', {
setup() {
objA = { __foo: 'FOO' };
- defineProperty(objA, 'foo', computed(function(key, value) {
- if (value !== undefined) {
+ defineProperty(objA, 'foo', computed({
+ get: function(key) {
+ return this['__'+key];
+ },
+ set: function(key, value) {
this['__'+key] = 'A '+value;
+ return this['__'+key];
}
- return this['__'+key];
}));
objB = create(objA);
objB.__foo = 'FOO';
- defineProperty(objB, 'foo', computed(function(key, value) {
- if (value !== undefined) {
+ defineProperty(objB, 'foo', computed({
+ get: function(key) { return this['__'+key]; },
+ set: function(key, value) {
this['__'+key] = 'B '+value;
+ return this['__'+key];
}
- return this['__'+key];
}));
},
@@ -218,10 +228,11 @@ QUnit.module('computed - cacheable', {
setup() {
obj = {};
count = 0;
- defineProperty(obj, 'foo', computed(function(key, value) {
+ var func = function(key, value) {
count++;
return 'bar '+count;
- }));
+ };
+ defineProperty(obj, 'foo', computed({ get: func, set: func }));
},
teardown() {
@@ -312,11 +323,12 @@ testBoth("setting a cached computed property passes the old value as the third a
var receivedOldValue;
- defineProperty(obj, 'plusOne', computed(
- function(key, value, oldValue) {
+ defineProperty(obj, 'plusOne', computed({
+ get: function() {},
+ set: function(key, value, oldValue) {
receivedOldValue = oldValue;
return value;
- }).property('foo')
+ } }).property('foo')
);
set(obj, 'plusOne', 1);
@@ -334,10 +346,12 @@ testBoth("the old value is only passed in if the computed property specifies thr
foo: 0
};
- defineProperty(obj, 'plusOne', computed(
- function(key, value) {
- equal(arguments.length, 2, "computed property is only invoked with two arguments");
- return value;
+ defineProperty(obj, 'plusOne', computed({
+ get: function() {},
+ set: function(key, value) {
+ equal(arguments.length, 2, "computed property is only invoked with two arguments");
+ return value;
+ }
}).property('foo')
);
@@ -354,10 +368,14 @@ QUnit.module('computed - dependentkey', {
setup() {
obj = { bar: 'baz' };
count = 0;
- defineProperty(obj, 'foo', computed(function(key, value) {
+ var getterAndSetter = function(key, value) {
count++;
get(this, 'bar');
return 'bar '+count;
+ };
+ defineProperty(obj, 'foo', computed({
+ get: getterAndSetter,
+ set: getterAndSetter
}).property('bar'));
},
@@ -416,13 +434,13 @@ testBoth('should invalidate multiple nested dependent keys', function(get, set)
});
testBoth('circular keys should not blow up', function(get, set) {
-
- defineProperty(obj, 'bar', computed(function(key, value) {
+ var func = function(key, value) {
count++;
return 'bar '+count;
- }).property('foo'));
+ };
+ defineProperty(obj, 'bar', computed({ get: func, set: func }).property('foo'));
- defineProperty(obj, 'foo', computed(function(key, value) {
+ defineProperty(obj, 'foo', computed(function(key) {
count++;
return 'foo '+count;
}).property('bar'));
@@ -459,7 +477,7 @@ testBoth('redefining a property should undo old dependent keys', function(get, s
});
testBoth('can watch multiple dependent keys specified declaratively via brace expansion', function (get, set) {
- defineProperty(obj, 'foo', computed(function(key, value) {
+ defineProperty(obj, 'foo', computed(function(key) {
count++;
return 'foo '+count;
}).property('qux.{bar,baz}'));
@@ -483,7 +501,7 @@ testBoth('can watch multiple dependent keys specified declaratively via brace ex
testBoth('throws assertion if brace expansion notation has spaces', function (get, set) {
throws(function () {
- defineProperty(obj, 'roo', computed(function (key, value) {
+ defineProperty(obj, 'roo', computed(function (key) {
count++;
return 'roo ' + count;
}).property('fee.{bar, baz,bop , }'));
@@ -705,6 +723,15 @@ if (Ember.FEATURES.isEnabled("new-computed-syntax")) {
testObj.set('sampleCP', 'abcd');
ok(testObj.get('sampleCP') === 'set-value', 'The return value of the CP was cached');
});
+
+ QUnit.test('Passing a function that acts both as getter and setter is deprecated', function() {
+ var regex = /Using the same function as getter and setter is deprecated/;
+ expectDeprecation(function() {
+ Ember.Object.extend({
+ aInt: computed('a', function(keyName, value, oldValue) {})
+ });
+ }, regex);
+ });
}
// ..........................................................
@@ -730,12 +757,14 @@ testBoth("when setting a value after it had been retrieved empty don't pass func
var obj = {};
var oldValueIsNoFunction = true;
- defineProperty(obj, 'foo', computed(function(key, value, oldValue) {
- if (typeof oldValue === 'function') {
- oldValueIsNoFunction = false;
+ defineProperty(obj, 'foo', computed({
+ get: function() { },
+ set: function(key, value, oldValue) {
+ if (typeof oldValue === 'function') {
+ oldValueIsNoFunction = false;
+ }
+ return undefined;
}
-
- return undefined;
}));
get(obj, 'foo');
@@ -751,15 +780,14 @@ testBoth('setting a watched computed property', function(get, set) {
firstName: 'Yehuda',
lastName: 'Katz'
};
- defineProperty(obj, 'fullName', computed(
- function(key, value) {
- if (arguments.length > 1) {
+ defineProperty(obj, 'fullName', computed({
+ get: function() { return get(this, 'firstName') + ' ' + get(this, 'lastName'); },
+ set: function(key, value) {
var values = value.split(' ');
set(this, 'firstName', values[0]);
set(this, 'lastName', values[1]);
return value;
}
- return get(this, 'firstName') + ' ' + get(this, 'lastName');
}).property('firstName', 'lastName')
);
var fullNameWillChange = 0;
@@ -809,13 +837,12 @@ testBoth('setting a cached computed property that modifies the value you give it
var obj = {
foo: 0
};
- defineProperty(obj, 'plusOne', computed(
- function(key, value) {
- if (arguments.length > 1) {
+ defineProperty(obj, 'plusOne', computed({
+ get: function(key) { return get(this, 'foo') + 1; },
+ set: function(key, value) {
set(this, 'foo', value);
return value + 1;
}
- return get(this, 'foo') + 1;
}).property('foo')
);
var plusOneWillChange = 0;
@@ -963,8 +990,9 @@ testBoth('computed.alias set', function(get, set) {
var obj = {};
var constantValue = 'always `a`';
- defineProperty(obj, 'original', computed(function(key, value) {
- return constantValue;
+ defineProperty(obj, 'original', computed({
+ get: function(key) { return constantValue; },
+ set: function(key, value) { return constantValue; }
}));
defineProperty(obj, 'aliased', alias('original'));
| true |
Other | emberjs | ember.js | f3d645dccd9464a20fdb82d59b12ebded131596e.json | Use new cps (get/set) internally | packages/ember-metal/tests/mixin/computed_test.js | @@ -51,7 +51,7 @@ QUnit.test('overriding computed properties', function() {
equal(get(obj, 'aProp'), 'AD', "should define super for D");
obj = { };
- defineProperty(obj, 'aProp', computed(function(key, value) {
+ defineProperty(obj, 'aProp', computed(function(key) {
return 'obj';
}));
MixinD.apply(obj);
@@ -66,19 +66,16 @@ QUnit.test('calling set on overridden computed properties', function() {
var superSetOccurred = false;
SuperMixin = Mixin.create({
- aProp: computed(function(key, val) {
- if (arguments.length === 1) {
- superGetOccurred = true;
- } else {
- superSetOccurred = true;
- }
- return true;
+ aProp: computed({
+ get: function(key) { superGetOccurred = true; },
+ set: function(key, value) { superSetOccurred = true; }
})
});
SubMixin = Mixin.create(SuperMixin, {
- aProp: computed(function(key, val) {
- return this._super.apply(this, arguments);
+ aProp: computed({
+ get: function(key) { return this._super.apply(this, arguments); },
+ set: function(key, value) { return this._super.apply(this, arguments); }
})
});
@@ -112,12 +109,14 @@ QUnit.test('setter behavior works properly when overriding computed properties',
var cpWasCalled = false;
var MixinB = Mixin.create({
- cpWithSetter2: computed(function(k, v) {
- cpWasCalled = true;
+ cpWithSetter2: computed({
+ get: K,
+ set: function(k, v) { cpWasCalled = true; }
}),
- cpWithSetter3: computed(function(k, v) {
- cpWasCalled = true;
+ cpWithSetter3: computed({
+ get: K,
+ set: function(k, v) { cpWasCalled = true; }
}),
cpWithoutSetter: computed(function(k) { | true |
Other | emberjs | ember.js | f3d645dccd9464a20fdb82d59b12ebded131596e.json | Use new cps (get/set) internally | packages/ember-metal/tests/observer_test.js | @@ -1028,9 +1028,9 @@ testBoth('setting simple prop should not trigger', function(get, set) {
testBoth('setting a cached computed property whose value has changed should trigger', function(get, set) {
var obj = {};
- defineProperty(obj, 'foo', computed(function(key, value) {
- if (arguments.length === 2) { return value; }
- return get(this, 'baz');
+ defineProperty(obj, 'foo', computed({
+ get: function() { return get(this, 'baz'); },
+ set: function(key, value) { return value; }
}).property('baz'));
var count = 0;
@@ -1070,11 +1070,9 @@ testBoth("immediate observers should fire synchronously", function(get, set) {
mixin.apply(obj);
- defineProperty(obj, 'foo', computed(function(key, value) {
- if (arguments.length > 1) {
- return value;
- }
- return "yes hello this is foo";
+ defineProperty(obj, 'foo', computed({
+ get: function() { return "yes hello this is foo"; },
+ set: function(key, value) { return value; }
}));
equal(get(obj, 'foo'), "yes hello this is foo", "precond - computed property returns a value");
@@ -1105,11 +1103,9 @@ if (Ember.EXTEND_PROTOTYPES) {
mixin.apply(obj);
- defineProperty(obj, 'foo', computed(function(key, value) {
- if (arguments.length > 1) {
- return value;
- }
- return "yes hello this is foo";
+ defineProperty(obj, 'foo', computed({
+ get: function(key) { return "yes hello this is foo"; },
+ set: function(key, value) { return value; }
}));
equal(get(obj, 'foo'), "yes hello this is foo", "precond - computed property returns a value");
@@ -1139,11 +1135,9 @@ testBoth('immediate observers watching multiple properties via brace expansion f
mixin.apply(obj);
- defineProperty(obj, 'foo', computed(function(key, value) {
- if (arguments.length > 1) {
- return value;
- }
- return "yes hello this is foo";
+ defineProperty(obj, 'foo', computed({
+ get: function() { return "yes hello this is foo"; },
+ set: function(key, value) { return value; }
}));
equal(get(obj, 'foo'), "yes hello this is foo", "precond - computed property returns a value"); | true |
Other | emberjs | ember.js | f3d645dccd9464a20fdb82d59b12ebded131596e.json | Use new cps (get/set) internally | packages/ember-metal/tests/watching/unwatch_test.js | @@ -28,12 +28,14 @@ function addListeners(obj, keyPath) {
testBoth('unwatching a computed property - regular get/set', function(get, set) {
var obj = {};
- defineProperty(obj, 'foo', computed(function(keyName, value) {
- if (value !== undefined) {
+ defineProperty(obj, 'foo', computed({
+ get: function() {
+ return this.__foo;
+ },
+ set: function(keyName, value) {
this.__foo = value;
+ return this.__foo;
}
-
- return this.__foo;
}));
addListeners(obj, 'foo');
| true |
Other | emberjs | ember.js | f3d645dccd9464a20fdb82d59b12ebded131596e.json | Use new cps (get/set) internally | packages/ember-metal/tests/watching/watch_test.js | @@ -40,12 +40,16 @@ function addListeners(obj, keyPath) {
testBoth('watching a computed property', function(get, set) {
var obj = {};
- Ember.defineProperty(obj, 'foo', Ember.computed(function(keyName, value) {
- if (value !== undefined) {
- this.__foo = value;
+ Ember.defineProperty(obj, 'foo', Ember.computed({
+ get: function() {
+ return this.__foo;
+ },
+ set: function(keyName, value) {
+ if (value !== undefined) {
+ this.__foo = value;
+ }
+ return this.__foo;
}
-
- return this.__foo;
}));
addListeners(obj, 'foo');
| true |
Other | emberjs | ember.js | f3d645dccd9464a20fdb82d59b12ebded131596e.json | Use new cps (get/set) internally | packages/ember-routing-views/lib/views/link.js | @@ -270,10 +270,15 @@ var LinkView = EmberComponent.extend({
When `true` interactions with the element will not trigger route changes.
@property disabled
*/
- disabled: computed(function computeLinkViewDisabled(key, value) {
- if (value !== undefined) { this.set('_isDisabled', value); }
+ disabled: computed({
+ get: function(key, value) {
+ return false;
+ },
+ set: function(key, value) {
+ if (value !== undefined) { this.set('_isDisabled', value); }
- return value ? get(this, 'disabledClass') : false;
+ return value ? get(this, 'disabledClass') : false;
+ }
}),
/** | true |
Other | emberjs | ember.js | f3d645dccd9464a20fdb82d59b12ebded131596e.json | Use new cps (get/set) internally | packages/ember-runtime/lib/controllers/array_controller.js | @@ -204,8 +204,11 @@ export default ArrayProxy.extend(ControllerMixin, SortableMixin, {
this._subControllers = [];
},
- model: computed(function (key, value) {
- if (arguments.length > 1) {
+ model: computed({
+ get: function(key) {
+ return Ember.A();
+ },
+ set: function(key, value) {
Ember.assert(
'ArrayController expects `model` to implement the Ember.Array mixin. ' +
'This can often be fixed by wrapping your model with `Ember.A()`.',
@@ -214,8 +217,6 @@ export default ArrayProxy.extend(ControllerMixin, SortableMixin, {
return value;
}
-
- return Ember.A();
}),
/** | true |
Other | emberjs | ember.js | f3d645dccd9464a20fdb82d59b12ebded131596e.json | Use new cps (get/set) internally | packages/ember-runtime/lib/ext/rsvp.js | @@ -25,7 +25,7 @@ RSVP.configure('async', function(callback, promise) {
if (Ember.testing && async) { asyncStart(); }
- run.backburner.schedule('actions', function(){
+ run.backburner.schedule('actions', function() {
if (Ember.testing && async) { asyncEnd(); }
callback(promise);
}); | true |
Other | emberjs | ember.js | f3d645dccd9464a20fdb82d59b12ebded131596e.json | Use new cps (get/set) internally | packages/ember-runtime/lib/mixins/array.js | @@ -167,12 +167,14 @@ export default Mixin.create(Enumerable, {
@property []
@return this
*/
- '[]': computed(function(key, value) {
- if (value !== undefined) {
+ '[]': computed({
+ get: function(key) {
+ return this;
+ },
+ set: function(key, value) {
this.replace(0, get(this, 'length'), value);
+ return this;
}
-
- return this;
}),
firstObject: computed(function() { | true |
Other | emberjs | ember.js | f3d645dccd9464a20fdb82d59b12ebded131596e.json | Use new cps (get/set) internally | packages/ember-runtime/lib/mixins/enumerable.js | @@ -956,8 +956,8 @@ export default Mixin.create({
@type Array
@return this
*/
- '[]': computed(function(key, value) {
- return this;
+ '[]': computed({
+ get: function(key) { return this; }
}),
// .......................................................... | true |
Other | emberjs | ember.js | f3d645dccd9464a20fdb82d59b12ebded131596e.json | Use new cps (get/set) internally | packages/ember-runtime/lib/mixins/promise_proxy.js | @@ -156,11 +156,12 @@ export default Mixin.create({
@property promise
*/
- promise: computed(function(key, promise) {
- if (arguments.length === 2) {
- return tap(this, promise);
- } else {
+ promise: computed({
+ get: function() {
throw new EmberError("PromiseProxy's promise must be set");
+ },
+ set: function(key, promise) {
+ return tap(this, promise);
}
}),
| true |
Other | emberjs | ember.js | f3d645dccd9464a20fdb82d59b12ebded131596e.json | Use new cps (get/set) internally | packages/ember-runtime/lib/mixins/sortable.js | @@ -161,26 +161,28 @@ export default Mixin.create(MutableEnumerable, {
@property arrangedContent
*/
- arrangedContent: computed('content', 'sortProperties.@each', function(key, value) {
- var content = get(this, 'content');
- var isSorted = get(this, 'isSorted');
- var sortProperties = get(this, 'sortProperties');
- var self = this;
-
- if (content && isSorted) {
- content = content.slice();
- content.sort(function(item1, item2) {
- return self.orderBy(item1, item2);
- });
- forEach(content, function(item) {
- forEach(sortProperties, function(sortProperty) {
- addObserver(item, sortProperty, this, 'contentItemSortPropertyDidChange');
+ arrangedContent: computed('content', 'sortProperties.@each', {
+ get: function(key) {
+ var content = get(this, 'content');
+ var isSorted = get(this, 'isSorted');
+ var sortProperties = get(this, 'sortProperties');
+ var self = this;
+
+ if (content && isSorted) {
+ content = content.slice();
+ content.sort(function(item1, item2) {
+ return self.orderBy(item1, item2);
+ });
+ forEach(content, function(item) {
+ forEach(sortProperties, function(sortProperty) {
+ addObserver(item, sortProperty, this, 'contentItemSortPropertyDidChange');
+ }, this);
}, this);
- }, this);
- return Ember.A(content);
- }
+ return Ember.A(content);
+ }
- return content;
+ return content;
+ }
}),
_contentWillChange: beforeObserver('content', function() { | true |
Other | emberjs | ember.js | f3d645dccd9464a20fdb82d59b12ebded131596e.json | Use new cps (get/set) internally | packages/ember-runtime/tests/legacy_1x/mixins/observable/observable_test.js | @@ -238,11 +238,14 @@ QUnit.module("object.set()", {
// computed property
_computed: "computed",
- computed: computed(function(key, value) {
- if (value !== undefined) {
+ computed: computed({
+ get: function(key) {
+ return this._computed;
+ },
+ set: function(key, value) {
this._computed = value;
+ return this._computed;
}
- return this._computed;
}).volatile(),
// method, but not a property
@@ -322,38 +325,62 @@ QUnit.module("Computed properties", {
// REGULAR
computedCalls: [],
- computed: computed(function(key, value) {
- this.computedCalls.push(value);
- return 'computed';
+ computed: computed({
+ get: function() {
+ this.computedCalls.push('getter-called');
+ return 'computed';
+ },
+ set: function(key, value) {
+ this.computedCalls.push(value);
+ }
}).volatile(),
computedCachedCalls: [],
- computedCached: computed(function(key, value) {
- this.computedCachedCalls.push(value);
- return 'computedCached';
+ computedCached: computed({
+ get: function() {
+ this.computedCachedCalls.push('getter-called');
+ return 'computedCached';
+ },
+ set: function(key, value) {
+ this.computedCachedCalls.push(value);
+ }
}),
-
// DEPENDENT KEYS
changer: 'foo',
dependentCalls: [],
- dependent: computed(function(key, value) {
- this.dependentCalls.push(value);
- return 'dependent';
+ dependent: computed({
+ get: function() {
+ this.dependentCalls.push('getter-called');
+ return 'dependent';
+ },
+ set: function(key, value) {
+ this.dependentCalls.push(value);
+ }
}).property('changer').volatile(),
dependentFrontCalls: [],
- dependentFront: computed('changer', function(key, value) {
- this.dependentFrontCalls.push(value);
- return 'dependentFront';
+ dependentFront: computed('changer', {
+ get: function() {
+ this.dependentFrontCalls.push('getter-called');
+ return 'dependentFront';
+ },
+ set: function(key, value) {
+ this.dependentFrontCalls.push(value);
+ }
}).volatile(),
dependentCachedCalls: [],
- dependentCached: computed(function(key, value) {
- this.dependentCachedCalls.push(value);
- return 'dependentCached';
+ dependentCached: computed({
+ get: function() {
+ this.dependentCachedCalls.push('getter-called!');
+ return 'dependentCached';
+ },
+ set: function(key, value) {
+ this.dependentCachedCalls.push(value);
+ }
}).property('changer'),
// every time it is recomputed, increments call
@@ -364,26 +391,31 @@ QUnit.module("Computed properties", {
// depends on cached property which depends on another property...
nestedIncCallCount: 0,
- nestedInc: computed(function(key, value) {
+ nestedInc: computed(function(key) {
get(this, 'inc');
return this.nestedIncCallCount++;
}).property('inc'),
// two computed properties that depend on a third property
state: 'on',
- isOn: computed(function(key, value) {
- if (value !== undefined) {
+ isOn: computed({
+ get: function() {
+ return this.get('state') === 'on';
+ },
+ set: function(key, value) {
this.set('state', 'on');
+ return this.get('state') === 'on';
}
-
- return this.get('state') === 'on';
}).property('state').volatile(),
- isOff: computed(function(key, value) {
- if (value !== undefined) {
+ isOff: computed({
+ get: function() {
+ return this.get('state') === 'off';
+ },
+ set: function(key, value) {
this.set('state', 'off');
+ return this.get('state') === 'off';
}
- return this.get('state') === 'off';
}).property('state').volatile()
}); | true |
Other | emberjs | ember.js | f3d645dccd9464a20fdb82d59b12ebded131596e.json | Use new cps (get/set) internally | packages/ember-runtime/tests/legacy_1x/mixins/observable/propertyChanges_test.js | @@ -123,12 +123,12 @@ QUnit.test("should invalidate function property cache when notifyPropertyChange
var a = ObservableObject.createWithMixins({
_b: null,
- b: computed(function(key, value) {
- if (value !== undefined) {
+ b: computed({
+ get: function() { return this._b; },
+ set: function(key, value) {
this._b = value;
return this;
}
- return this._b;
}).volatile()
});
| true |
Other | emberjs | ember.js | f3d645dccd9464a20fdb82d59b12ebded131596e.json | Use new cps (get/set) internally | packages/ember-runtime/tests/mixins/observable_test.js | @@ -46,11 +46,9 @@ testBoth('calling setProperties completes safely despite exceptions', function(g
var obj = EmberObject.createWithMixins({
firstName: "Steve",
lastName: "Jobs",
- companyName: computed(function(key, value) {
- if (value !== undefined) {
- throw exc;
- }
- return "Apple, Inc.";
+ companyName: computed({
+ get: function() { return "Apple, Inc."; },
+ set: function(key, value) { throw exc; }
})
});
| true |
Other | emberjs | ember.js | f3d645dccd9464a20fdb82d59b12ebded131596e.json | Use new cps (get/set) internally | packages/ember-runtime/tests/system/object/create_test.js | @@ -31,9 +31,13 @@ QUnit.test("simple properties are set", function() {
QUnit.test("calls computed property setters", function() {
var MyClass = EmberObject.extend({
- foo: computed(function(key, val) {
- if (arguments.length === 2) { return val; }
- return "this is not the value you're looking for";
+ foo: computed({
+ get: function() {
+ return "this is not the value you're looking for";
+ },
+ set: function(key, value) {
+ return value;
+ }
})
});
| true |
Other | emberjs | ember.js | f3d645dccd9464a20fdb82d59b12ebded131596e.json | Use new cps (get/set) internally | packages/ember-runtime/tests/system/object_proxy_test.js | @@ -8,11 +8,12 @@ QUnit.module("ObjectProxy");
testBoth("should not proxy properties passed to create", function (get, set) {
var Proxy = ObjectProxy.extend({
- cp: computed(function (key, value) {
- if (value) {
+ cp: computed({
+ get: function(key) { return this._cp; },
+ set: function(key, value) {
this._cp = value;
+ return this._cp;
}
- return this._cp;
})
});
var proxy = Proxy.create({ | true |
Other | emberjs | ember.js | f3d645dccd9464a20fdb82d59b12ebded131596e.json | Use new cps (get/set) internally | packages/ember-views/lib/mixins/view_context_support.js | @@ -16,12 +16,13 @@ var ViewContextSupport = Mixin.create({
@property context
@type Object
*/
- context: computed(function(key, value) {
- if (arguments.length === 2) {
+ context: computed({
+ get: function() {
+ return get(this, '_context');
+ },
+ set: function(key, value) {
set(this, '_context', value);
return value;
- } else {
- return get(this, '_context');
}
}).volatile(),
@@ -43,23 +44,23 @@ var ViewContextSupport = Mixin.create({
@property _context
@private
*/
- _context: computed(function(key, value) {
- if (arguments.length === 2) {
+ _context: computed({
+ get: function() {
+ var parentView, controller;
+
+ if (controller = get(this, 'controller')) {
+ return controller;
+ }
+
+ parentView = this._parentView;
+ if (parentView) {
+ return get(parentView, '_context');
+ }
+ return null;
+ },
+ set: function(key, value) {
return value;
}
-
- var parentView, controller;
-
- if (controller = get(this, 'controller')) {
- return controller;
- }
-
- parentView = this._parentView;
- if (parentView) {
- return get(parentView, '_context');
- }
-
- return null;
}),
_controller: null,
@@ -71,18 +72,18 @@ var ViewContextSupport = Mixin.create({
@property controller
@type Object
*/
- controller: computed(function(key, value) {
- if (arguments.length === 2) {
+ controller: computed({
+ get: function() {
+ if (this._controller) {
+ return this._controller;
+ }
+
+ return this._parentView ? get(this._parentView, 'controller') : null;
+ },
+ set: function(_, value) {
this._controller = value;
return value;
}
-
- if (this._controller) {
- return this._controller;
- }
-
- var parentView = this._parentView;
- return parentView ? get(parentView, 'controller') : null;
})
});
| true |
Other | emberjs | ember.js | f3d645dccd9464a20fdb82d59b12ebded131596e.json | Use new cps (get/set) internally | packages/ember-views/lib/views/component.js | @@ -145,15 +145,18 @@ var Component = View.extend(TargetActionSupport, ComponentTemplateDeprecation, {
@deprecated
@property template
*/
- template: computed(function(key, value) {
- if (value !== undefined) { return value; }
+ template: computed({
+ get: function() {
+ var templateName = get(this, 'templateName');
+ var template = this.templateForName(templateName, 'template');
- var templateName = get(this, 'templateName');
- var template = this.templateForName(templateName, 'template');
+ Ember.assert("You specified the templateName " + templateName + " for " + this + ", but it did not exist.", !templateName || !!template);
- Ember.assert("You specified the templateName " + templateName + " for " + this + ", but it did not exist.", !templateName || !!template);
-
- return template || get(this, 'defaultTemplate');
+ return template || get(this, 'defaultTemplate');
+ },
+ set: function(key, value) {
+ return value;
+ }
}).property('templateName'),
/** | true |
Other | emberjs | ember.js | f3d645dccd9464a20fdb82d59b12ebded131596e.json | Use new cps (get/set) internally | packages/ember-views/lib/views/select.js | @@ -430,11 +430,15 @@ var Select = View.extend({
@type String
@default null
*/
- value: computed('_valuePath', 'selection', function(key, value) {
- if (arguments.length === 2) { return value; }
- var valuePath = get(this, '_valuePath');
- return valuePath ? get(this, 'selection.' + valuePath) : get(this, 'selection');
- }),
+ value: computed({
+ get: function(key) {
+ var valuePath = get(this, '_valuePath');
+ return valuePath ? get(this, 'selection.' + valuePath) : get(this, 'selection');
+ },
+ set: function(key, value) {
+ return value;
+ }
+ }).property('_valuePath', 'selection'),
/**
If given, a top-most dummy option will be rendered to serve as a user | true |
Other | emberjs | ember.js | f3d645dccd9464a20fdb82d59b12ebded131596e.json | Use new cps (get/set) internally | packages/ember-views/lib/views/view.js | @@ -727,15 +727,18 @@ var View = CoreView.extend(
@property template
@type Function
*/
- template: computed('templateName', function(key, value) {
- if (value !== undefined) { return value; }
- var templateName = get(this, 'templateName');
- var template = this.templateForName(templateName, 'template');
-
- Ember.assert("You specified the templateName " + templateName + " for " + this + ", but it did not exist.", !templateName || !!template);
-
- return template || get(this, 'defaultTemplate');
+ template: computed('templateName', {
+ get: function() {
+ var templateName = get(this, 'templateName');
+ var template = this.templateForName(templateName, 'template');
+ Ember.assert("You specified the templateName " + templateName + " for " + this + ", but it did not exist.", !templateName || !!template);
+ return template || get(this, 'defaultTemplate');
+ },
+ set: function(key, value) {
+ if (value !== undefined) { return value; }
+ return get(this, key);
+ }
}),
/** | true |
Other | emberjs | ember.js | 3a25949b2c0f2e50e348c601185dc2eee043a423.json | Add KeyStream tests | packages/ember-views/tests/streams/key_stream_test.js | @@ -0,0 +1,131 @@
+import { set } from "ember-metal/property_set";
+import Stream from "ember-metal/streams/stream";
+import KeyStream from "ember-views/streams/key_stream";
+
+var source, object, count;
+
+function incrementCount() {
+ count++;
+}
+
+QUnit.module('KeyStream', {
+ setup: function() {
+ count = 0;
+ object = { name: "mmun" };
+
+ source = new Stream(function() {
+ return object;
+ });
+
+ source.setValue = function(value) {
+ object = value;
+ this.notify();
+ };
+ },
+ teardown: function() {
+ count = undefined;
+ object = undefined;
+ source = undefined;
+ }
+});
+
+QUnit.test("can be instantiated manually", function() {
+ var nameStream = new KeyStream(source, 'name');
+ equal(nameStream.value(), "mmun", "Stream value is correct");
+});
+
+QUnit.test("can be instantiated via `Stream.prototype.get`", function() {
+ var nameStream = source.get('name');
+ equal(nameStream.value(), "mmun", "Stream value is correct");
+});
+
+QUnit.test("is notified when the observed object's property is mutated", function() {
+ var nameStream = source.get('name');
+ nameStream.subscribe(incrementCount);
+
+ equal(count, 0, "Subscribers called correct number of times");
+ equal(nameStream.value(), "mmun", "Stream value is correct");
+
+ set(object, 'name', "wycats");
+
+ equal(count, 1, "Subscribers called correct number of times");
+ equal(nameStream.value(), "wycats", "Stream value is correct");
+});
+
+QUnit.test("is notified when the source stream's value changes to a new object", function() {
+ var nameStream = source.get('name');
+ nameStream.subscribe(incrementCount);
+
+ equal(count, 0, "Subscribers called correct number of times");
+ equal(nameStream.value(), "mmun", "Stream value is correct");
+
+ object = { name: "wycats" };
+ source.setValue(object);
+
+ equal(count, 1, "Subscribers called correct number of times");
+ equal(nameStream.value(), "wycats", "Stream value is correct");
+
+ set(object, 'name', "kris");
+
+ equal(count, 2, "Subscribers called correct number of times");
+ equal(nameStream.value(), "kris", "Stream value is correct");
+});
+
+QUnit.test("is notified when the source stream's value changes to the same object", function() {
+ var nameStream = source.get('name');
+ nameStream.subscribe(incrementCount);
+
+ equal(count, 0, "Subscribers called correct number of times");
+ equal(nameStream.value(), "mmun", "Stream value is correct");
+
+ source.setValue(object);
+
+ equal(count, 1, "Subscribers called correct number of times");
+ equal(nameStream.value(), "mmun", "Stream value is correct");
+
+ set(object, 'name', "kris");
+
+ equal(count, 2, "Subscribers called correct number of times");
+ equal(nameStream.value(), "kris", "Stream value is correct");
+});
+
+QUnit.test("is notified when setSource is called with a new stream whose value is a new object", function() {
+ var nameStream = source.get('name');
+ nameStream.subscribe(incrementCount);
+
+ equal(count, 0, "Subscribers called correct number of times");
+ equal(nameStream.value(), "mmun", "Stream value is correct");
+
+ object = { name: "wycats" };
+ nameStream.setSource(new Stream(function() {
+ return object;
+ }));
+
+ equal(count, 1, "Subscribers called correct number of times");
+ equal(nameStream.value(), "wycats", "Stream value is correct");
+
+ set(object, 'name', "kris");
+
+ equal(count, 2, "Subscribers called correct number of times");
+ equal(nameStream.value(), "kris", "Stream value is correct");
+});
+
+QUnit.test("is notified when setSource is called with a new stream whose value is the same object", function() {
+ var nameStream = source.get('name');
+ nameStream.subscribe(incrementCount);
+
+ equal(count, 0, "Subscribers called correct number of times");
+ equal(nameStream.value(), "mmun", "Stream value is correct");
+
+ nameStream.setSource(new Stream(function() {
+ return object;
+ }));
+
+ equal(count, 1, "Subscribers called correct number of times");
+ equal(nameStream.value(), "mmun", "Stream value is correct");
+
+ set(object, 'name', "kris");
+
+ equal(count, 2, "Subscribers called correct number of times");
+ equal(nameStream.value(), "kris", "Stream value is correct");
+}); | false |
Other | emberjs | ember.js | 306f75cd555336302c3e5295cba141e92cca2f5f.json | Fix bad syntax in docs. | packages/ember-routing/lib/system/router.js | @@ -894,10 +894,10 @@ EmberRouter.reopenClass({
supplied callback function using `this.resource` and `this.route`.
```javascript
- App.Router.map(function({
+ App.Router.map(function(){
this.route('about');
this.resource('article');
- }));
+ });
```
For more detailed examples please see | false |
Other | emberjs | ember.js | 4a82e7287f2a00d13690aefd1b04c9d223116889.json | Update HTMLBars version to 0.11.2. | package.json | @@ -22,7 +22,7 @@
"express": "^4.5.0",
"github": "^0.2.3",
"glob": "~4.3.2",
- "htmlbars": "git+https://github.com/stefanpenner/htmlbars-private.git",
+ "htmlbars": "0.11.2",
"qunit-extras": "^1.3.0",
"qunitjs": "^1.16.0",
"route-recognizer": "0.1.5", | false |
Other | emberjs | ember.js | b339c671df7bcbdfdd9381ede4faf56f5f405b36.json | Remove Ember.Descriptor from exports | packages/ember-metal/lib/computed.js | @@ -108,7 +108,6 @@ function UNDEFINED() { }
@class ComputedProperty
@namespace Ember
- @extends Ember.Descriptor
@constructor
*/
function ComputedProperty(config, opts) { | true |
Other | emberjs | ember.js | b339c671df7bcbdfdd9381ede4faf56f5f405b36.json | Remove Ember.Descriptor from exports | packages/ember-metal/lib/injected_property.js | @@ -9,7 +9,6 @@ import create from "ember-metal/platform/create";
@class InjectedProperty
@namespace Ember
- @extends Ember.Descriptor
@constructor
@param {String} type The container type the property will lookup
@param {String} name (optional) The name the property will lookup, defaults | true |
Other | emberjs | ember.js | b339c671df7bcbdfdd9381ede4faf56f5f405b36.json | Remove Ember.Descriptor from exports | packages/ember-metal/lib/main.js | @@ -303,7 +303,6 @@ Ember.beginPropertyChanges = beginPropertyChanges;
Ember.endPropertyChanges = endPropertyChanges;
Ember.changeProperties = changeProperties;
-Ember.Descriptor = Descriptor;
Ember.defineProperty = defineProperty;
Ember.set = set; | true |
Other | emberjs | ember.js | b339c671df7bcbdfdd9381ede4faf56f5f405b36.json | Remove Ember.Descriptor from exports | packages/ember-metal/lib/mixin.js | @@ -770,7 +770,6 @@ Alias.prototype = new Descriptor();
@method aliasMethod
@for Ember
@param {String} methodName name of the method to alias
- @return {Ember.Descriptor}
*/
export function aliasMethod(methodName) {
return new Alias(methodName); | true |
Other | emberjs | ember.js | b339c671df7bcbdfdd9381ede4faf56f5f405b36.json | Remove Ember.Descriptor from exports | packages/ember-metal/lib/properties.js | @@ -16,13 +16,6 @@ import { overrideChains } from "ember-metal/property_events";
/**
Objects of this type can implement an interface to respond to requests to
get and set. The default implementation handles simple properties.
-
- You generally won't need to create or subclass this directly.
-
- @class Descriptor
- @namespace Ember
- @private
- @constructor
*/
export function Descriptor() {
this.isDescriptor = true;
@@ -55,7 +48,7 @@ export function DEFAULT_GETTER_FUNCTION(name) {
properties and other special descriptors.
Normally this method takes only three parameters. However if you pass an
- instance of `Ember.Descriptor` as the third param then you can pass an
+ instance of `Descriptor` as the third param then you can pass an
optional value as the fourth parameter. This is often more efficient than
creating new descriptor hashes for each property.
@@ -84,7 +77,7 @@ export function DEFAULT_GETTER_FUNCTION(name) {
@for Ember
@param {Object} obj the object to define this property on. This may be a prototype.
@param {String} keyName the name of the property
- @param {Ember.Descriptor} [desc] an instance of `Ember.Descriptor` (typically a
+ @param {Descriptor} [desc] an instance of `Descriptor` (typically a
computed property) or an ES5 descriptor.
You must provide this or `data` but not both.
@param {*} [data] something other than a descriptor, that will | true |
Other | emberjs | ember.js | 8ebca79ae105752cfd8452a8b2f41aeb1aedb54a.json | Update mutable_array example
Change quotes to single, and add some line breaks | packages/ember-runtime/lib/mixins/mutable_array.js | @@ -72,7 +72,8 @@ export default Mixin.create(EmberArray, MutableEnumerable, {
want to reuse an existing array without having to recreate it.
```javascript
- var colors = ["red", "green", "blue"];
+ var colors = ['red', 'green', 'blue'];
+
color.length(); // 3
colors.clear(); // []
colors.length(); // 0
@@ -96,9 +97,10 @@ export default Mixin.create(EmberArray, MutableEnumerable, {
specified index.
```javascript
- var colors = ["red", "green", "blue"];
- colors.insertAt(2, "yellow"); // ["red", "green", "yellow", "blue"]
- colors.insertAt(5, "orange"); // Error: Index out of range
+ var colors = ['red', 'green', 'blue'];
+
+ colors.insertAt(2, 'yellow'); // ['red', 'green', 'yellow', 'blue']
+ colors.insertAt(5, 'orange'); // Error: Index out of range
```
@method insertAt
@@ -123,9 +125,10 @@ export default Mixin.create(EmberArray, MutableEnumerable, {
length this method will throw an `OUT_OF_RANGE_EXCEPTION`.
```javascript
- var colors = ["red", "green", "blue", "yellow", "orange"];
- colors.removeAt(0); // ["green", "blue", "yellow", "orange"]
- colors.removeAt(2, 2); // ["green", "blue"]
+ var colors = ['red', 'green', 'blue', 'yellow', 'orange'];
+
+ colors.removeAt(0); // ['green', 'blue', 'yellow', 'orange']
+ colors.removeAt(2, 2); // ['green', 'blue']
colors.removeAt(4, 2); // Error: Index out of range
```
@@ -157,9 +160,10 @@ export default Mixin.create(EmberArray, MutableEnumerable, {
is KVO-compliant.
```javascript
- var colors = ["red", "green"];
- colors.pushObject("black"); // ["red", "green", "black"]
- colors.pushObject(["yellow"]); // ["red", "green", ["yellow"]]
+ var colors = ['red', 'green'];
+
+ colors.pushObject('black'); // ['red', 'green', 'black']
+ colors.pushObject(['yellow']); // ['red', 'green', ['yellow']]
```
@method pushObject
@@ -176,8 +180,9 @@ export default Mixin.create(EmberArray, MutableEnumerable, {
notifying observers of the change until all objects are added.
```javascript
- var colors = ["red"];
- colors.pushObjects(["yellow", "orange"]); // ["red", "yellow", "orange"]
+ var colors = ['red'];
+
+ colors.pushObjects(['yellow', 'orange']); // ['red', 'yellow', 'orange']
```
@method pushObjects
@@ -197,9 +202,10 @@ export default Mixin.create(EmberArray, MutableEnumerable, {
it is KVO-compliant.
```javascript
- var colors = ["red", "green", "blue"];
- colors.popObject(); // "blue"
- console.log(colors); // ["red", "green"]
+ var colors = ['red', 'green', 'blue'];
+
+ colors.popObject(); // 'blue'
+ console.log(colors); // ['red', 'green']
```
@method popObject
@@ -221,9 +227,10 @@ export default Mixin.create(EmberArray, MutableEnumerable, {
like `shift()` but it is KVO-compliant.
```javascript
- var colors = ["red", "green", "blue"];
- colors.shiftObject(); // "red"
- console.log(colors); // ["green", "blue"]
+ var colors = ['red', 'green', 'blue'];
+
+ colors.shiftObject(); // 'red'
+ console.log(colors); // ['green', 'blue']
```
@method shiftObject
@@ -244,9 +251,10 @@ export default Mixin.create(EmberArray, MutableEnumerable, {
KVO-compliant.
```javascript
- var colors = ["red"];
- colors.unshiftObject("yellow"); // ["yellow", "red"]
- colors.unshiftObject(["black"]); // [["black"], "yellow", "red"]
+ var colors = ['red'];
+
+ colors.unshiftObject('yellow'); // ['yellow', 'red']
+ colors.unshiftObject(['black']); // [['black'], 'yellow', 'red']
```
@method unshiftObject
@@ -263,9 +271,10 @@ export default Mixin.create(EmberArray, MutableEnumerable, {
observers until all objects have been added.
```javascript
- var colors = ["red"];
- colors.unshiftObjects(["black", "white"]); // ["black", "white", "red"]
- colors.unshiftObjects("yellow"); // Type Error: 'undefined' is not a function
+ var colors = ['red'];
+
+ colors.unshiftObjects(['black', 'white']); // ['black', 'white', 'red']
+ colors.unshiftObjects('yellow'); // Type Error: 'undefined' is not a function
```
@method unshiftObjects
@@ -300,8 +309,9 @@ export default Mixin.create(EmberArray, MutableEnumerable, {
If argument is an empty array receiver will be cleared.
```javascript
- var colors = ["red", "green", "blue"];
- colors.setObjects(["black", "white"]); // ["black", "white"]
+ var colors = ['red', 'green', 'blue'];
+
+ colors.setObjects(['black', 'white']); // ['black', 'white']
colors.setObjects([]); // []
```
@@ -328,10 +338,11 @@ export default Mixin.create(EmberArray, MutableEnumerable, {
Remove all occurrences of an object in the array.
```javascript
- var cities = ["Chicago", "Berlin", "Lima", "Chicago"];
- cities.removeObject("Chicago"); // ["Berlin", "Lima"]
- cities.removeObject("Lima"); // ["Berlin"]
- cities.removeObject("Tokyo") // ["Berlin"]
+ var cities = ['Chicago', 'Berlin', 'Lima', 'Chicago'];
+
+ cities.removeObject('Chicago'); // ['Berlin', 'Lima']
+ cities.removeObject('Lima'); // ['Berlin']
+ cities.removeObject('Tokyo') // ['Berlin']
```
@method removeObject
@@ -355,9 +366,10 @@ export default Mixin.create(EmberArray, MutableEnumerable, {
present in the array.
```javascript
- var cities = ["Chicago", "Berlin"];
- cities.addObject("Lima"); // ["Chicago", "Berlin", "Lima"]
- cities.addObject("Berlin"); // ["Chicago", "Berlin", "Lima"]
+ var cities = ['Chicago', 'Berlin'];
+
+ cities.addObject('Lima'); // ['Chicago', 'Berlin', 'Lima']
+ cities.addObject('Berlin'); // ['Chicago', 'Berlin', 'Lima']
```
@method addObject
@@ -371,5 +383,4 @@ export default Mixin.create(EmberArray, MutableEnumerable, {
return this;
}
-
}); | false |
Other | emberjs | ember.js | 6a71ff26042f2e6f9516f9616d88159a2acd8bec.json | Use less container trickery
thanks @igorT | packages/ember-application/lib/system/application.js | @@ -333,10 +333,7 @@ var Application = Namespace.extend(DeferredMixin, {
// For the default instance only, set the view registry to the global
// Ember.View.views hash for backwards-compatibility.
- var registry = instance.applicationRegistry;
- registry.unregister('-view-registry:main');
- registry.register('-view-registry:main', EmberView.views);
- registry.optionsForType('-view-registry', { instantiate: false });
+ EmberView.views = instance.container.lookup('-view-registry:main');
// TODO2.0: Legacy support for App.__container__
// and global methods on App that rely on a single, | false |
Other | emberjs | ember.js | c6747547f5c1f73c64167c443e633c31867b2172.json | Deprecate direct use of CoreView | packages/ember-views/lib/main.js | @@ -24,7 +24,7 @@ import {
states
} from "ember-views/views/states";
-import CoreView from "ember-views/views/core_view";
+import { DeprecatedCoreView } from "ember-views/views/core_view";
import View from "ember-views/views/view";
import ContainerView from "ember-views/views/container_view";
import CollectionView from "ember-views/views/collection_view";
@@ -68,7 +68,7 @@ ViewUtils.isSimpleClick = isSimpleClick;
ViewUtils.getViewClientRects = getViewClientRects;
ViewUtils.getViewBoundingClientRect = getViewBoundingClientRect;
-Ember.CoreView = CoreView;
+Ember.CoreView = DeprecatedCoreView;
Ember.View = View;
Ember.View.states = states;
Ember.View.cloneStates = cloneStates; | true |
Other | emberjs | ember.js | c6747547f5c1f73c64167c443e633c31867b2172.json | Deprecate direct use of CoreView | packages/ember-views/lib/views/core_view.js | @@ -34,6 +34,7 @@ var renderer;
@class CoreView
@namespace Ember
@extends Ember.Object
+ @deprecated Use `Ember.View` instead.
@uses Ember.Evented
@uses Ember.ActionHandler
*/
@@ -153,4 +154,11 @@ CoreView.reopenClass({
isViewClass: true
});
+export var DeprecatedCoreView = CoreView.extend({
+ init: function() {
+ Ember.deprecate('Ember.CoreView is deprecated. Please use Ember.View.', false);
+ this._super.apply(this, arguments);
+ }
+});
+
export default CoreView; | true |
Other | emberjs | ember.js | c6747547f5c1f73c64167c443e633c31867b2172.json | Deprecate direct use of CoreView | packages/ember-views/tests/views/exports_test.js | @@ -0,0 +1,9 @@
+import Ember from "ember-views";
+
+QUnit.module("ember-view exports");
+
+QUnit.test("should export a disabled CoreView", function() {
+ expectDeprecation(function() {
+ Ember.CoreView.create();
+ }, 'Ember.CoreView is deprecated. Please use Ember.View.');
+}); | true |
Other | emberjs | ember.js | ad79c1e075987bea64d3a73e703363d07284338a.json | Enable sourcemap support for Ember development.
This is useful while developing on Ember, and we may possibly publish
the maps to `bower`, S3, etc in the future, but we need to be careful to
not cause many errors/warnings while building Ember CLI (if the `.map`
file is referenced but not present it causes a console warning). | .travis.yml | @@ -20,6 +20,7 @@ script:
env:
global:
+ - DISABLE_SOURCE_MAPS=true
- BROCCOLI_ENV=production
- S3_BUILD_CACHE_BUCKET=emberjs-build-cache
- S3_BUCKET_NAME=builds.emberjs.com | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.