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 | 4561c61bcf9c84ae146e509cbd9e7a5b9a5245ba.json | Remove trailing whitespace | packages/ember-htmlbars/lib/helpers/with.js | @@ -52,7 +52,7 @@ import shouldDisplay from "ember-views/streams/should_display";
{{#if isProlificBlogger}}
{{user.name}} has written more than {{posts.model.length}} blog posts!
{{else}}
- {{user.name}} has only written {{posts.model.length}} blog posts.
+ {{user.name}} has only written {{posts.model.length}} blog posts.
{{/if}}
{{/with}}
``` | false |
Other | emberjs | ember.js | 898d24d11d20bd802809dcee7cedfcbf78655dac.json | Make template in documentation for {{each}} valid. | packages/ember-htmlbars/lib/helpers/each.js | @@ -53,7 +53,7 @@ import normalizeSelf from "ember-htmlbars/utils/normalize-self";
```javascript
App.NoPeopleView = Ember.View.extend({
tagName: 'li',
- template: 'No person is available, sorry'
+ template: '<p>No person is available, sorry</p>'
});
```
| false |
Other | emberjs | ember.js | c8f6731de12314b87a71054fd3ae87413c15c3c8.json | Add Vim swp files to .gitignore | .gitignore | @@ -39,3 +39,4 @@ publish_to_bower/
bower_components/
npm-debug.log
.ember-cli
+*.swp | false |
Other | emberjs | ember.js | 826d33d2b6eaf178ac65a22d455b41e4a4c5b205.json | Fix documentation for {{with}} helper. | packages/ember-htmlbars/lib/helpers/with.js | @@ -10,35 +10,56 @@ import shouldDisplay from "ember-views/streams/should_display";
Use the `{{with}}` helper when you want to alias a property to a new name. This is helpful
for semantic clarity as it allows you to retain default scope or to reference a property from another
`{{with}}` block.
+
If the aliased property is "falsey", for example: `false`, `undefined` `null`, `""`, `0` or
an empty array, the block will not be rendered.
+
```handlebars
- // will only render if user.posts contains items
+ {{! Will only render if user.posts contains items}}
{{#with user.posts as |blogPosts|}}
<div class="notice">
There are {{blogPosts.length}} blog posts written by {{user.name}}.
</div>
- {{#each post in blogPosts}}
+ {{#each blogPosts as |post|}}
<li>{{post.title}}</li>
{{/each}}
{{/with}}
```
+
Without the `as` operator, it would be impossible to reference `user.name` in the example above.
+
NOTE: The alias should not reuse a name from the bound property path.
- For example: `{{#with foo.bar as foo}}` is not supported because it attempts to alias using
- the first part of the property path, `foo`. Instead, use `{{#with foo.bar as baz}}`.
+ For example: `{{#with foo.bar as |foo|}}` is not supported because it attempts to alias using
+ the first part of the property path, `foo`. Instead, use `{{#with foo.bar as |baz|}}`.
+
### `controller` option
- Adding `controller='something'` instructs the `{{with}}` helper to create and use an instance of
- the specified controller wrapping the aliased keyword.
- This is very similar to using an `itemController` option with the `{{each}}` helper.
+
+ Adding `controller='someController'` instructs the `{{with}}` helper to create and use an instance of
+ the specified controller wrapping the aliased keyword. This is very similar to using an
+ `itemController` option with the [{{each}}](/api/classes/Ember.Handlebars.helpers.html#method_each) helper.
+
+ ```javascript
+ App.UserBlogPostsController = Ember.Controller.extend({
+ isProlificBlogger: function() {
+ return this.get('model.length') > 5;
+ }.property('model.length')
+ })
+ ```
+
```handlebars
{{#with users.posts controller='userBlogPosts' as |posts|}}
- {{!- `posts` is wrapped in our controller instance }}
+ {{! `posts` is wrapped in our controller instance }}
+ {{#if isProlificBlogger}}
+ {{user.name}} has written more than {{posts.model.length}} blog posts!
+ {{else}}
+ {{user.name}} has only written {{posts.model.length}} blog posts.
+ {{/if}}
{{/with}}
```
- In the above example, the `posts` keyword is now wrapped in the `userBlogPost` controller,
- which provides an elegant way to decorate the context with custom
- functions/properties.
+
+ In the above example, the `posts` keyword is now wrapped in the `userBlogPosts` controller,
+ which provides an elegant way to decorate the context with custom functions/properties.
+
@method with
@for Ember.Handlebars.helpers
@param {Function} context | false |
Other | emberjs | ember.js | 82fd051b09b2814fa098f21a493eec73bd8e6074.json | Fix documentation for {{each}} helper. | packages/ember-htmlbars/lib/helpers/each.js | @@ -2,6 +2,151 @@ import { get } from "ember-metal/property_get";
import { forEach } from "ember-metal/enumerable_utils";
import normalizeSelf from "ember-htmlbars/utils/normalize-self";
+/**
+ The `{{#each}}` helper loops over elements in a collection. It is an extension
+ of the base Handlebars `{{#each}}` helper.
+
+ The default behavior of `{{#each}}` is to yield its inner block once for every
+ item in an array.
+
+ ```javascript
+ var developers = [{name: 'Yehuda'},{name: 'Tom'}, {name: 'Paul'}];
+ ```
+
+ ```handlebars
+ {{#each developers as |person|}}
+ {{person.name}}
+ {{! `this` is whatever it was outside the #each }}
+ {{/each}}
+ ```
+
+ The same rules apply to arrays of primitives.
+
+ ```javascript
+ var developerNames = ['Yehuda', 'Tom', 'Paul']
+ ```
+
+ ```handlebars
+ {{#each developerNames as |name|}}
+ {{name}}
+ {{/each}}
+ ```
+
+ ### {{else}} condition
+
+ `{{#each}}` can have a matching `{{else}}`. The contents of this block will render
+ if the collection is empty.
+
+ ```handlebars
+ {{#each developers as |person|}}
+ {{person.name}}
+ {{else}}
+ <p>Sorry, nobody is available for this task.</p>
+ {{/each}}
+ ```
+
+ ### Specifying an alternative view for each item
+
+ `itemViewClass` can control which view will be used during the render of each
+ item's template. The following template:
+
+ ```handlebars
+ <ul>
+ {{#each developers itemViewClass="person" as |developer|}}
+ {{developer.name}}
+ {{/each}}
+ </ul>
+ ```
+
+ Will use the following view for each item:
+
+ ```javascript
+ App.PersonView = Ember.View.extend({
+ tagName: 'li'
+ });
+ ```
+
+ Resulting in HTML output that looks like the following:
+
+ ```html
+ <ul>
+ <li class="ember-view">Yehuda</li>
+ <li class="ember-view">Tom</li>
+ <li class="ember-view">Paul</li>
+ </ul>
+ ```
+
+ `itemViewClass` also enables a non-block form of `{{each}}`. The view
+ must [provide its own template](/api/classes/Ember.View.html#toc_templates)
+ and then the block should be dropped. An example that outputs the same HTML
+ as the previous one:
+
+ ```javascript
+ App.PersonView = Ember.View.extend({
+ tagName: 'li',
+ template: '{{developer.name}}'
+ });
+ ```
+
+ ```handlebars
+ <ul>
+ {{each developers itemViewClass="person" as |developer|}}
+ </ul>
+ ```
+
+ ### Specifying an alternative view for no items (else)
+
+ The `emptyViewClass` option provides the same flexibility to the `{{else}}`
+ case of the each helper.
+
+ ```javascript
+ App.NoPeopleView = Ember.View.extend({
+ tagName: 'li',
+ template: 'No person is available, sorry'
+ });
+ ```
+
+ ```handlebars
+ <ul>
+ {{#each developers emptyViewClass="no-people" as |developer|}}
+ <li>{{developer.name}}</li>
+ {{/each}}
+ </ul>
+ ```
+
+ ### Wrapping each item in a controller
+
+ Controllers in Ember manage state and decorate data. In many cases,
+ providing a controller for each item in a list can be useful.
+ An item that is passed to an item controller will be set as the `model` property
+ on the controller.
+
+ This allows state and decoration to be added to the controller
+ while any other property lookups can be delegated to the model. An example:
+
+ ```javascript
+ App.RecruitController = Ember.Controller.extend({
+ isAvailableForHire: function() {
+ return !this.get('model.isEmployed') && this.get('model.isSeekingWork');
+ }.property('model.isEmployed', 'model.isSeekingWork')
+ })
+ ```
+
+ ```handlebars
+ {{#each developers itemController="recruit" as |person|}}
+ {{person.model.name}} {{#if person.isAvailableForHire}}Hire me!{{/if}}
+ {{/each}}
+ ```
+
+ @method each
+ @for Ember.Handlebars.helpers
+ @param [name] {String} name for item (used with `as`)
+ @param [path] {String} path
+ @param [options] {Object} Handlebars key/value pairs of options
+ @param [options.itemViewClass] {String} a path to a view class used for each item
+ @param [options.emptyViewClass] {String} a path to a view class used for each item
+ @param [options.itemController] {String} name of a controller to be created for each item
+*/
export default function eachHelper(params, hash, blocks) {
var list = params[0];
var keyPath = hash.key; | false |
Other | emberjs | ember.js | 196b290a5a2955f7f1058c12c70ea42154667091.json | Add a better deprecation for `{{bind-attr}}`.
Example deprecation:
```
The `bind-attr` helper ('my-app-name/templates/index' @ L1:C7) is deprecated in favor of HTMLBars-style bound attributes");
``` | packages/ember-template-compiler/lib/plugins/transform-bind-attr-to-attributes.js | @@ -24,9 +24,10 @@ import { dasherize } from "ember-template-compiler/system/string";
@class TransformBindAttrToAttributes
@private
*/
-function TransformBindAttrToAttributes() {
+function TransformBindAttrToAttributes(options) {
// set later within HTMLBars to the syntax package
this.syntax = null;
+ this.options = options || {};
}
/**
@@ -36,14 +37,15 @@ function TransformBindAttrToAttributes() {
*/
TransformBindAttrToAttributes.prototype.transform = function TransformBindAttrToAttributes_transform(ast) {
var plugin = this;
+ var moduleName = this.options.moduleName;
var walker = new this.syntax.Walker();
walker.visit(ast, function(node) {
if (node.type === 'ElementNode') {
for (var i = 0; i < node.modifiers.length; i++) {
var modifier = node.modifiers[i];
- if (isBindAttrModifier(modifier)) {
+ if (isBindAttrModifier(modifier, moduleName)) {
node.modifiers.splice(i--, 1);
plugin.assignAttrs(node, modifier.hash);
}
@@ -156,13 +158,28 @@ TransformBindAttrToAttributes.prototype.parseClass = function parseClass(value)
}
};
-function isBindAttrModifier(modifier) {
+function isBindAttrModifier(modifier, moduleName) {
var name = modifier.path.original;
+ let { column, line } = modifier.path.loc.start || {};
+ let moduleInfo = '';
+
+ if (moduleName) {
+ moduleInfo += `'${moduleName}' @ `;
+ }
+
+ if (line && column) {
+ moduleInfo += `L${line}:C${column}`;
+ }
+
+ if (moduleInfo) {
+ moduleInfo = `(${moduleInfo}) `;
+ }
+
if (name === 'bind-attr' || name === 'bindAttr') {
Ember.deprecate(
- 'The `' + name + '` helper is deprecated in favor of ' +
- 'HTMLBars-style bound attributes'
+ 'The `' + name + '` helper ' + moduleInfo + 'is deprecated in favor of ' +
+ 'HTMLBars-style bound attributes.'
);
return true;
} else { | true |
Other | emberjs | ember.js | 196b290a5a2955f7f1058c12c70ea42154667091.json | Add a better deprecation for `{{bind-attr}}`.
Example deprecation:
```
The `bind-attr` helper ('my-app-name/templates/index' @ L1:C7) is deprecated in favor of HTMLBars-style bound attributes");
``` | packages/ember-template-compiler/tests/plugins/transform-bind-attr-to-attributes-test.js | @@ -6,16 +6,18 @@ QUnit.test("Using the `bind-attr` helper throws a deprecation", function() {
expect(1);
expectDeprecation(function() {
- compile('<div {{bind-attr class=view.foo}}></div>');
- }, /The `bind-attr` helper is deprecated in favor of HTMLBars-style bound attributes/);
+ compile('<div {{bind-attr class=view.foo}}></div>', {
+ moduleName: 'foo/bar/baz'
+ });
+ }, "The `bind-attr` helper ('foo/bar/baz' @ L1:C7) is deprecated in favor of HTMLBars-style bound attributes.");
});
QUnit.test("Using the `bindAttr` helper throws a deprecation", function() {
expect(1);
expectDeprecation(function() {
compile('<div {{bindAttr class=view.foo}}></div>');
- }, /The `bindAttr` helper is deprecated in favor of HTMLBars-style bound attributes/);
+ }, "The `bindAttr` helper (L1:C7) is deprecated in favor of HTMLBars-style bound attributes.");
});
QUnit.test("asserts for <div class='foo' {{bind-attr class='bar'}}></div>", function() { | true |
Other | emberjs | ember.js | b9e1c56456273351d01d9e79b67fb8ccf629d31b.json | Recognize array-likes in link-render-node
Affects if/unless and possibly other places. | packages/ember-htmlbars/lib/hooks/link-render-node.js | @@ -4,7 +4,7 @@
*/
import subscribe from "ember-htmlbars/utils/subscribe";
-import { isArray } from "ember-metal/utils";
+import { isArray } from "ember-runtime/utils";
import { chain, read, readArray, isStream, addDependency } from "ember-metal/streams/utils";
import { findHelper } from "ember-htmlbars/system/lookup-helper";
| true |
Other | emberjs | ember.js | b9e1c56456273351d01d9e79b67fb8ccf629d31b.json | Recognize array-likes in link-render-node
Affects if/unless and possibly other places. | packages/ember-htmlbars/tests/helpers/if_unless_test.js | @@ -5,6 +5,7 @@ import EmberView from "ember-views/views/view";
import ObjectProxy from "ember-runtime/system/object_proxy";
import EmberObject from "ember-runtime/system/object";
import compile from "ember-template-compiler/system/compile";
+import ArrayProxy from "ember-runtime/system/array_proxy";
import { set } from 'ember-metal/property_set';
import { fmt } from 'ember-runtime/system/string';
@@ -122,9 +123,9 @@ QUnit.test("The `if` helper updates if an object proxy gains or loses context",
equal(view.$().text(), '');
});
-QUnit.test("The `if` helper updates if an array is empty or not", function() {
+function testIfArray(array) {
view = EmberView.create({
- array: Ember.A(),
+ array: array,
template: compile('{{#if view.array}}Yep{{/if}}')
});
@@ -144,6 +145,15 @@ QUnit.test("The `if` helper updates if an array is empty or not", function() {
});
equal(view.$().text(), '');
+
+}
+
+QUnit.test("The `if` helper updates if an array is empty or not", function() {
+ testIfArray(Ember.A());
+});
+
+QUnit.test("The `if` helper updates if an array-like object is empty or not", function() {
+ testIfArray(ArrayProxy.create({ content: Ember.A([]) }));
});
QUnit.test("The `if` helper updates when the value changes", function() { | true |
Other | emberjs | ember.js | ed06f9ecc7af2e2191c319162630303540593c52.json | Remove non-HTMLBars template path.
Manually writing template functions is largely unsupported already.
This change removes a guard/check for `isHTMLBars` (we intend to stop
stamping all templates with this flag in the future). | packages/ember-views/lib/views/view.js | @@ -775,11 +775,7 @@ var View = CoreView.extend(
var template = get(this, 'template');
if (template) {
- if (template.isHTMLBars) {
- return template.render(context, options, { contextualElement: morph.contextualElement }).fragment;
- } else {
- return template(context, options);
- }
+ return template.render(context, options, { contextualElement: morph.contextualElement }).fragment;
}
},
| false |
Other | emberjs | ember.js | 5f1cba209b0025d976c3bd5053ea1eea052f5d73.json | Move instrumentation to the node managers
Components that don't have a view instance don't go through the
renderer. This insures instrumentation is invoked anyway.
Also moved system/component-node to node-managers/view-node-manager | packages/ember-htmlbars/lib/keywords/collection.js | @@ -5,7 +5,7 @@
import { readViewFactory } from "ember-views/streams/utils";
import CollectionView from "ember-views/views/collection_view";
-import ComponentNode from "ember-htmlbars/system/component-node";
+import ViewNodeManager from "ember-htmlbars/node-managers/view-node-manager";
import objectKeys from "ember-metal/keys";
import { assign } from "ember-metal/merge";
@@ -48,7 +48,7 @@ export default {
hash.emptyViewClass = hash.emptyView;
}
- var componentNode = ComponentNode.create(node, env, hash, options, parentView, null, scope, template);
+ var componentNode = ViewNodeManager.create(node, env, hash, options, parentView, null, scope, template);
state.manager = componentNode;
componentNode.render(env, hash, visitor); | true |
Other | emberjs | ember.js | 5f1cba209b0025d976c3bd5053ea1eea052f5d73.json | Move instrumentation to the node managers
Components that don't have a view instance don't go through the
renderer. This insures instrumentation is invoked anyway.
Also moved system/component-node to node-managers/view-node-manager | packages/ember-htmlbars/lib/keywords/customized_outlet.js | @@ -3,7 +3,7 @@
@submodule ember-htmlbars
*/
-import ComponentNode from "ember-htmlbars/system/component-node";
+import ViewNodeManager from "ember-htmlbars/node-managers/view-node-manager";
import { readViewFactory } from "ember-views/streams/utils";
import { isStream } from "ember-metal/streams/utils";
@@ -25,7 +25,7 @@ export default {
var options = {
component: state.viewClass
};
- var componentNode = ComponentNode.create(renderNode, env, hash, options, parentView, null, null, null);
+ var componentNode = ViewNodeManager.create(renderNode, env, hash, options, parentView, null, null, null);
state.manager = componentNode;
componentNode.render(env, hash, visitor);
} | true |
Other | emberjs | ember.js | 5f1cba209b0025d976c3bd5053ea1eea052f5d73.json | Move instrumentation to the node managers
Components that don't have a view instance don't go through the
renderer. This insures instrumentation is invoked anyway.
Also moved system/component-node to node-managers/view-node-manager | packages/ember-htmlbars/lib/keywords/real_outlet.js | @@ -4,7 +4,7 @@
*/
import { get } from "ember-metal/property_get";
-import ComponentNode from "ember-htmlbars/system/component-node";
+import ViewNodeManager from "ember-htmlbars/node-managers/view-node-manager";
import topLevelViewTemplate from "ember-htmlbars/templates/top-level-view";
topLevelViewTemplate.meta.revision = 'Ember@VERSION_STRING_PLACEHOLDER';
@@ -67,7 +67,7 @@ export default {
Ember.Logger.info("Rendering " + toRender.name + " with " + ViewClass, { fullName: 'view:' + toRender.name });
}
- var componentNode = ComponentNode.create(renderNode, env, {}, options, parentView, null, null, template);
+ var componentNode = ViewNodeManager.create(renderNode, env, {}, options, parentView, null, null, template);
state.manager = componentNode;
componentNode.render(env, hash, visitor); | true |
Other | emberjs | ember.js | 5f1cba209b0025d976c3bd5053ea1eea052f5d73.json | Move instrumentation to the node managers
Components that don't have a view instance don't go through the
renderer. This insures instrumentation is invoked anyway.
Also moved system/component-node to node-managers/view-node-manager | packages/ember-htmlbars/lib/keywords/view.js | @@ -5,7 +5,7 @@
import { readViewFactory } from "ember-views/streams/utils";
import EmberView from "ember-views/views/view";
-import ComponentNode from "ember-htmlbars/system/component-node";
+import ViewNodeManager from "ember-htmlbars/node-managers/view-node-manager";
import objectKeys from "ember-metal/keys";
export default {
@@ -45,7 +45,7 @@ export default {
var parentView = state.parentView;
var options = { component: node.state.viewClassOrInstance, layout: null };
- var componentNode = ComponentNode.create(node, env, hash, options, parentView, null, scope, template);
+ var componentNode = ViewNodeManager.create(node, env, hash, options, parentView, null, scope, template);
state.manager = componentNode;
componentNode.render(env, hash, visitor); | true |
Other | emberjs | ember.js | 5f1cba209b0025d976c3bd5053ea1eea052f5d73.json | Move instrumentation to the node managers
Components that don't have a view instance don't go through the
renderer. This insures instrumentation is invoked anyway.
Also moved system/component-node to node-managers/view-node-manager | packages/ember-htmlbars/lib/node-managers/component-node-manager.js | @@ -8,6 +8,7 @@ import { set } from "ember-metal/property_set";
import setProperties from "ember-metal/set_properties";
import View from "ember-views/views/view";
import { MUTABLE_CELL } from "ember-views/compat/attrs-proxy";
+import { instrument } from "ember-htmlbars/system/instrumentation-support";
// In theory this should come through the env, but it should
// be safe to import this until we make the hook system public
@@ -114,65 +115,70 @@ ComponentNodeManager.create = function(renderNode, env, options) {
ComponentNodeManager.prototype.render = function(env, visitor) {
var { component, attrs } = this;
- var newEnv = env;
- if (component) {
- newEnv = merge({}, env);
- newEnv.view = component;
- }
+ return instrument(component, function() {
- if (component) {
- var snapshot = takeSnapshot(attrs);
- env.renderer.setAttrs(this.component, snapshot);
- env.renderer.willCreateElement(component);
- env.renderer.willRender(component);
- env.renderedViews.push(component.elementId);
- }
+ var newEnv = env;
+ if (component) {
+ newEnv = merge({}, env);
+ newEnv.view = component;
+ }
- if (this.block) {
- this.block(newEnv, [], undefined, this.renderNode, this.scope, visitor);
- }
+ if (component) {
+ var snapshot = takeSnapshot(attrs);
+ env.renderer.setAttrs(this.component, snapshot);
+ env.renderer.willCreateElement(component);
+ env.renderer.willRender(component);
+ env.renderedViews.push(component.elementId);
+ }
- if (component) {
- var element = this.expectElement && this.renderNode.firstNode;
- env.renderer.didCreateElement(component, element); // 2.0TODO: Remove legacy hooks.
- env.renderer.willInsertElement(component, element);
- env.lifecycleHooks.push({ type: 'didInsertElement', view: component });
- }
+ if (this.block) {
+ this.block(newEnv, [], undefined, this.renderNode, this.scope, visitor);
+ }
+
+ if (component) {
+ var element = this.expectElement && this.renderNode.firstNode;
+ env.renderer.didCreateElement(component, element); // 2.0TODO: Remove legacy hooks.
+ env.renderer.willInsertElement(component, element);
+ env.lifecycleHooks.push({ type: 'didInsertElement', view: component });
+ }
+ }, this);
};
ComponentNodeManager.prototype.rerender = function(env, attrs, visitor) {
var component = this.component;
+ return instrument(component, function() {
- var newEnv = env;
- if (component) {
- newEnv = merge({}, env);
- newEnv.view = component;
+ var newEnv = env;
+ if (component) {
+ newEnv = merge({}, env);
+ newEnv.view = component;
- var snapshot = takeSnapshot(attrs);
+ var snapshot = takeSnapshot(attrs);
- // Notify component that it has become dirty and is about to change.
- env.renderer.willUpdate(component, snapshot);
+ // Notify component that it has become dirty and is about to change.
+ env.renderer.willUpdate(component, snapshot);
- if (component._renderNode.shouldReceiveAttrs) {
- env.renderer.updateAttrs(component, snapshot);
- setProperties(component, mergeBindings({}, shadowedAttrs(component, snapshot)));
- component._renderNode.shouldReceiveAttrs = false;
- }
+ if (component._renderNode.shouldReceiveAttrs) {
+ env.renderer.updateAttrs(component, snapshot);
+ setProperties(component, mergeBindings({}, shadowedAttrs(component, snapshot)));
+ component._renderNode.shouldReceiveAttrs = false;
+ }
- env.renderer.willRender(component);
+ env.renderer.willRender(component);
- env.renderedViews.push(component.elementId);
- }
+ env.renderedViews.push(component.elementId);
+ }
- if (this.block) {
- this.block(newEnv, [], undefined, this.renderNode, this.scope, visitor);
- }
+ if (this.block) {
+ this.block(newEnv, [], undefined, this.renderNode, this.scope, visitor);
+ }
- if (component) {
- env.lifecycleHooks.push({ type: 'didUpdate', view: component });
- }
+ if (component) {
+ env.lifecycleHooks.push({ type: 'didUpdate', view: component });
+ }
- return newEnv;
+ return newEnv;
+ }, this);
};
| true |
Other | emberjs | ember.js | 5f1cba209b0025d976c3bd5053ea1eea052f5d73.json | Move instrumentation to the node managers
Components that don't have a view instance don't go through the
renderer. This insures instrumentation is invoked anyway.
Also moved system/component-node to node-managers/view-node-manager | packages/ember-htmlbars/lib/node-managers/view-node-manager.js | @@ -8,6 +8,7 @@ import View from "ember-views/views/view";
import { MUTABLE_CELL } from "ember-views/compat/attrs-proxy";
import getCellOrValue from "ember-htmlbars/hooks/get-cell-or-value";
import SafeString from "htmlbars-util/safe-string";
+import { instrument } from "ember-htmlbars/system/instrumentation-support";
// In theory this should come through the env, but it should
// be safe to import this until we make the hook system public
@@ -90,79 +91,84 @@ ComponentNode.create = function(renderNode, env, attrs, found, parentView, path,
ComponentNode.prototype.render = function(env, attrs, visitor) {
var component = this.component;
- var newEnv = env;
- if (component) {
- newEnv = merge({}, env);
- newEnv.view = component;
- }
+ return instrument(component, function() {
- if (component) {
- var snapshot = takeSnapshot(attrs);
- env.renderer.setAttrs(this.component, snapshot);
- env.renderer.willCreateElement(component);
- env.renderer.willRender(component);
- env.renderedViews.push(component.elementId);
- }
+ var newEnv = env;
+ if (component) {
+ newEnv = merge({}, env);
+ newEnv.view = component;
+ }
- if (this.block) {
- this.block(newEnv, [], undefined, this.renderNode, this.scope, visitor);
- }
+ if (component) {
+ var snapshot = takeSnapshot(attrs);
+ env.renderer.setAttrs(this.component, snapshot);
+ env.renderer.willCreateElement(component);
+ env.renderer.willRender(component);
+ env.renderedViews.push(component.elementId);
+ }
- if (component) {
- var element = this.expectElement && this.renderNode.firstNode;
- if (component.render) {
- var content, node, lastChildIndex;
- var buffer = [];
- component.render(buffer);
- content = buffer.join('');
- if (element) {
- lastChildIndex = this.renderNode.childNodes.length - 1;
- node = this.renderNode.childNodes[lastChildIndex];
- } else {
- node = this.renderNode;
+ if (this.block) {
+ this.block(newEnv, [], undefined, this.renderNode, this.scope, visitor);
+ }
+
+ if (component) {
+ var element = this.expectElement && this.renderNode.firstNode;
+ if (component.render) {
+ var content, node, lastChildIndex;
+ var buffer = [];
+ component.render(buffer);
+ content = buffer.join('');
+ if (element) {
+ lastChildIndex = this.renderNode.childNodes.length - 1;
+ node = this.renderNode.childNodes[lastChildIndex];
+ } else {
+ node = this.renderNode;
+ }
+ node.setContent(new SafeString(content));
}
- node.setContent(new SafeString(content));
+
+ env.renderer.didCreateElement(component, element); // 2.0TODO: Remove legacy hooks.
+ env.renderer.willInsertElement(component, element);
+ env.lifecycleHooks.push({ type: 'didInsertElement', view: component });
}
+ }, this);
- env.renderer.didCreateElement(component, element); // 2.0TODO: Remove legacy hooks.
- env.renderer.willInsertElement(component, element);
- env.lifecycleHooks.push({ type: 'didInsertElement', view: component });
- }
};
ComponentNode.prototype.rerender = function(env, attrs, visitor) {
var component = this.component;
- var newEnv = env;
- if (component) {
- newEnv = merge({}, env);
- newEnv.view = component;
+ return instrument(component, function() {
+ var newEnv = env;
+ if (component) {
+ newEnv = merge({}, env);
+ newEnv.view = component;
- var snapshot = takeSnapshot(attrs);
+ var snapshot = takeSnapshot(attrs);
- // Notify component that it has become dirty and is about to change.
- env.renderer.willUpdate(component, snapshot);
+ // Notify component that it has become dirty and is about to change.
+ env.renderer.willUpdate(component, snapshot);
- if (component._renderNode.shouldReceiveAttrs) {
- env.renderer.updateAttrs(component, snapshot);
- setProperties(component, mergeBindings({}, shadowedAttrs(component, snapshot)));
- component._renderNode.shouldReceiveAttrs = false;
- }
+ if (component._renderNode.shouldReceiveAttrs) {
+ env.renderer.updateAttrs(component, snapshot);
+ setProperties(component, mergeBindings({}, shadowedAttrs(component, snapshot)));
+ component._renderNode.shouldReceiveAttrs = false;
+ }
- env.renderer.willRender(component);
+ env.renderer.willRender(component);
- env.renderedViews.push(component.elementId);
- }
-
- if (this.block) {
- this.block(newEnv, [], undefined, this.renderNode, this.scope, visitor);
- }
+ env.renderedViews.push(component.elementId);
+ }
+ if (this.block) {
+ this.block(newEnv, [], undefined, this.renderNode, this.scope, visitor);
+ }
- if (component) {
- env.lifecycleHooks.push({ type: 'didUpdate', view: component });
- }
+ if (component) {
+ env.lifecycleHooks.push({ type: 'didUpdate', view: component });
+ }
- return newEnv;
+ return newEnv;
+ }, this);
};
export function createOrUpdateComponent(component, options, renderNode, env, attrs = {}) { | true |
Other | emberjs | ember.js | 5f1cba209b0025d976c3bd5053ea1eea052f5d73.json | Move instrumentation to the node managers
Components that don't have a view instance don't go through the
renderer. This insures instrumentation is invoked anyway.
Also moved system/component-node to node-managers/view-node-manager | packages/ember-htmlbars/lib/system/instrumentation-support.js | @@ -0,0 +1,41 @@
+import {
+ _instrumentStart,
+ subscribers
+} from "ember-metal/instrumentation";
+
+/**
+ * Provides instrumentation for node managers.
+ *
+ * Wrap your node manager's render and re-render methods
+ * with this function.
+ *
+ * @param {Object} component Component or View instance (optional)
+ * @param {Function} callback The function to instrument
+ * @param {Object} context The context to call the function with
+ * @return {Object} Return value from the invoked callback
+ */
+export function instrument(component, callback, context) {
+ var instrumentName, val, details, end;
+ // Only instrument if there's at least one subscriber.
+ if (subscribers.length) {
+ if (component) {
+ instrumentName = component.instrumentName;
+ } else {
+ instrumentName = 'node';
+ }
+ details = {};
+ if (component) {
+ component.instrumentDetails(details);
+ }
+ end = _instrumentStart('render.' + instrumentName, function viewInstrumentDetails() {
+ return details;
+ });
+ val = callback.call(context);
+ if (end) {
+ end();
+ }
+ return val;
+ } else {
+ return callback.call(context);
+ }
+} | true |
Other | emberjs | ember.js | 5f1cba209b0025d976c3bd5053ea1eea052f5d73.json | Move instrumentation to the node managers
Components that don't have a view instance don't go through the
renderer. This insures instrumentation is invoked anyway.
Also moved system/component-node to node-managers/view-node-manager | packages/ember-htmlbars/lib/system/render-view.js | @@ -1,5 +1,5 @@
import defaultEnv from "ember-htmlbars/env";
-import ComponentNode, { createOrUpdateComponent } from "ember-htmlbars/system/component-node";
+import ViewNodeManager, { createOrUpdateComponent } from "ember-htmlbars/node-managers/view-node-manager";
// 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.
@@ -19,7 +19,7 @@ export function renderHTMLBarsBlock(view, block, renderNode) {
view.env = env;
createOrUpdateComponent(view, {}, renderNode, env);
- var componentNode = new ComponentNode(view, null, renderNode, block, view.tagName !== '');
+ var componentNode = new ViewNodeManager(view, null, renderNode, block, view.tagName !== '');
componentNode.render(env, {});
} | true |
Other | emberjs | ember.js | 5f1cba209b0025d976c3bd5053ea1eea052f5d73.json | Move instrumentation to the node managers
Components that don't have a view instance don't go through the
renderer. This insures instrumentation is invoked anyway.
Also moved system/component-node to node-managers/view-node-manager | packages/ember-metal-views/lib/renderer.js | @@ -1,10 +1,6 @@
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";
import { indexOf } from "ember-metal/enumerable_utils";
//import { deprecation } from "ember-views/compat/attrs-proxy";
@@ -120,15 +116,8 @@ Renderer.prototype.createElement =
this.prerenderTopLevelView(view, morph);
};
-Renderer.prototype.willCreateElement = function (view) {
- if (subscribers.length && view.instrumentDetails) {
- view._instrumentEnd = _instrumentStart('render.'+view.instrumentName, function viewInstrumentDetails() {
- var details = {};
- view.instrumentDetails(details);
- return details;
- });
- }
-}; // inBuffer
+// inBuffer
+Renderer.prototype.willCreateElement = function (/*view*/) {};
Renderer.prototype.didCreateElement = function (view, element) {
if (element) {
@@ -138,9 +127,6 @@ Renderer.prototype.didCreateElement = function (view, element) {
if (view._transitionTo) {
view._transitionTo('hasElement');
}
- if (view._instrumentEnd) {
- view._instrumentEnd();
- }
}; // hasElement
Renderer.prototype.willInsertElement = function (view) {
@@ -209,7 +195,7 @@ Renderer.prototype.renderElementRemoval =
}
};
-Renderer.prototype.willRemoveElement = function (view) {};
+Renderer.prototype.willRemoveElement = function (/*view*/) {};
Renderer.prototype.willDestroyElement = function (view) {
if (view._willDestroyElement) { | true |
Other | emberjs | ember.js | 5f1cba209b0025d976c3bd5053ea1eea052f5d73.json | Move instrumentation to the node managers
Components that don't have a view instance don't go through the
renderer. This insures instrumentation is invoked anyway.
Also moved system/component-node to node-managers/view-node-manager | packages/ember-routing-htmlbars/lib/keywords/render.js | @@ -6,7 +6,7 @@ import { isStream, read } from "ember-metal/streams/utils";
import { camelize } from "ember-runtime/system/string";
import generateController from "ember-routing/system/generate_controller";
import { generateControllerFactory } from "ember-routing/system/generate_controller";
-import ComponentNode from "ember-htmlbars/system/component-node";
+import ViewNodeManager from "ember-htmlbars/node-managers/view-node-manager";
export default {
willRender(renderNode, env) {
@@ -164,7 +164,7 @@ export default {
options.component = view;
}
- var componentNode = ComponentNode.create(node, env, hash, options, state.parentView, null, null, template);
+ var componentNode = ViewNodeManager.create(node, env, hash, options, state.parentView, null, null, template);
state.manager = componentNode;
if (router && params.length === 1) { | true |
Other | emberjs | ember.js | 5f1cba209b0025d976c3bd5053ea1eea052f5d73.json | Move instrumentation to the node managers
Components that don't have a view instance don't go through the
renderer. This insures instrumentation is invoked anyway.
Also moved system/component-node to node-managers/view-node-manager | packages/ember/tests/view_instrumentation_test.js | @@ -0,0 +1,64 @@
+import EmberHandlebars from "ember-htmlbars/compat";
+import run from "ember-metal/run_loop";
+import $ from "ember-views/system/jquery";
+import { subscribe, unsubscribe } from "ember-metal/instrumentation";
+
+var compile = EmberHandlebars.compile;
+
+var App, $fixture;
+
+function setupExample() {
+ // setup templates
+ Ember.TEMPLATES.application = compile("{{outlet}}");
+ Ember.TEMPLATES.index = compile("<h1>Node 1</h1>");
+ Ember.TEMPLATES.posts = compile("<h1>Node 1</h1>");
+
+ App.Router.map(function() {
+ this.route('posts');
+ });
+}
+
+function handleURL(path) {
+ var router = App.__container__.lookup('router:main');
+ return run(router, 'handleURL', path);
+}
+
+QUnit.module("View Instrumentation", {
+ setup() {
+ run(function() {
+ App = Ember.Application.create({
+ rootElement: '#qunit-fixture'
+ });
+ App.deferReadiness();
+
+ App.Router.reopen({
+ location: 'none'
+ });
+ });
+
+ $fixture = $('#qunit-fixture');
+ setupExample();
+ },
+
+ teardown() {
+ run(App, 'destroy');
+ App = null;
+ Ember.TEMPLATES = {};
+ }
+});
+
+QUnit.test("Nodes without view instances are instrumented", function(assert) {
+ var called = false;
+ var subscriber = subscribe('render', {
+ before() {
+ called = true;
+ },
+ after() {}
+ });
+ run(App, 'advanceReadiness');
+ assert.ok(called, 'Instrumentation called on first render');
+ called = false;
+ handleURL('/posts');
+ assert.ok(called, 'instrumentation called on transition to non-view backed route');
+ unsubscribe(subscriber);
+}); | true |
Other | emberjs | ember.js | e05feec0d52a4f66308b6547434897b2c01fca60.json | fix automatic mut for non-streams | packages/ember-htmlbars/lib/keywords/mut.js | @@ -2,6 +2,8 @@ import create from "ember-metal/platform/create";
import merge from "ember-metal/merge";
import { symbol } from "ember-metal/utils";
import ProxyStream from "ember-metal/streams/proxy-stream";
+import { isStream } from "ember-metal/streams/utils";
+import Stream from "ember-metal/streams/stream";
import { MUTABLE_CELL } from "ember-views/compat/attrs-proxy";
export let MUTABLE_REFERENCE = symbol("MUTABLE_REFERENCE");
@@ -27,12 +29,23 @@ export function privateMut(morph, env, scope, originalParams, hash, template, in
}
function mutParam(read, stream, internal) {
+ if (internal) {
+ if (!isStream(stream)) {
+ let literal = stream;
+ stream = new Stream(function() { return literal; }, `(literal ${literal})`);
+ stream.setValue = function(newValue) {
+ literal = newValue;
+ stream.notify();
+ };
+ }
+ } else {
+ Ember.assert("You can only pass a path to mut", isStream(stream));
+ }
+
if (stream[MUTABLE_REFERENCE]) {
return stream;
}
- Ember.assert("You can only pass a path to mut", internal || typeof stream.setValue === 'function');
-
return new MutStream(stream);
}
| true |
Other | emberjs | ember.js | e05feec0d52a4f66308b6547434897b2c01fca60.json | fix automatic mut for non-streams | packages/ember-htmlbars/tests/integration/mutable_binding_test.js | @@ -273,6 +273,73 @@ QUnit.test('a mutable binding with a backing computed property and attribute pre
assert.strictEqual(bottom.attrs.thingy.value, 14, "the set took effect");
});
+QUnit.test('automatic mutable bindings tolerate undefined non-stream inputs', function(assert) {
+ registry.register('template:components/x-outer', compile('{{x-inner model=attrs.nonexistent}}'));
+ registry.register('template:components/x-inner', compile('hello'));
+
+ view = EmberView.create({
+ container: container,
+ template: compile('{{x-outer}}')
+ });
+
+ runAppend(view);
+ assert.strictEqual(view.$().text(), "hello");
+});
+
+QUnit.test('automatic mutable bindings tolerate constant non-stream inputs', function(assert) {
+ registry.register('template:components/x-outer', compile('{{x-inner model="foo"}}'));
+ registry.register('template:components/x-inner', compile('hello{{attrs.model}}'));
+
+ view = EmberView.create({
+ container: container,
+ template: compile('{{x-outer}}')
+ });
+
+ runAppend(view);
+ assert.strictEqual(view.$().text(), "hellofoo");
+});
+
+QUnit.test('automatic mutable bindings to undefined non-streams tolerate attempts to set them', function(assert) {
+ var inner;
+
+ registry.register('template:components/x-outer', compile('{{x-inner model=attrs.nonexistent}}'));
+ registry.register('component:x-inner', Component.extend({
+ didInsertElement() {
+ inner = this;
+ }
+ }));
+
+ view = EmberView.create({
+ container: container,
+ template: compile('{{x-outer}}')
+ });
+
+ runAppend(view);
+ run(() => inner.attrs.model.update(42));
+ assert.equal(inner.attrs.model.value, 42);
+});
+
+QUnit.test('automatic mutable bindings to constant non-streams tolerate attempts to set them', function(assert) {
+ var inner;
+
+ registry.register('template:components/x-outer', compile('{{x-inner model=attrs.x}}'));
+ registry.register('component:x-inner', Component.extend({
+ didInsertElement() {
+ inner = this;
+ }
+ }));
+
+ view = EmberView.create({
+ container: container,
+ template: compile('{{x-outer x="foo"}}')
+ });
+
+ runAppend(view);
+ run(() => inner.attrs.model.update(42));
+ assert.equal(inner.attrs.model.value, 42);
+});
+
+
// jscs:disable validateIndentation
if (Ember.FEATURES.isEnabled('ember-htmlbars-component-generation')) {
| true |
Other | emberjs | ember.js | 5107da66e567895edb821d1440ba4e4cc5e5d4bb.json | Fix a cycle caused by legacy semantics
Consider a component like this:
```js
// my-component.js
Component.extend({
thingy: null
});
```
And an invocation like this:
```hbs
{{my-component thingy=(mut someValue)}}
```
(note that `mut` is the default for old-style component invocations)
In this case, because `my-component` has an explicit `thingy` property,
we set the property on rendering and re-rerendering for backwards
compatibility reasons.
Because `attrs.thingy` is a mutable cell, when we try to set `thingy` on
`my-component` during re-render, its `update` method is invoked, which
clobbers the original `someValue` unexpectedly. When `someValue` is a
computed property, the results can be catastrophic.
This commit avoids invoking `update` on a mutable cell in this
situation, avoiding this unnecessary cycle. | packages/ember-views/lib/compat/attrs-proxy.js | @@ -110,14 +110,8 @@ let AttrsProxyMixin = {
};
AttrsProxyMixin[PROPERTY_DID_CHANGE] = function(key) {
- let attrs = this.attrs;
-
- if (attrs && key in attrs) {
- let possibleCell = attrs[key];
-
- if (possibleCell && possibleCell[MUTABLE_CELL]) {
- possibleCell.update(get(this, key));
- }
+ if (this.currentState) {
+ this.currentState.legacyPropertyDidChange(this, key);
}
};
| true |
Other | emberjs | ember.js | 5107da66e567895edb821d1440ba4e4cc5e5d4bb.json | Fix a cycle caused by legacy semantics
Consider a component like this:
```js
// my-component.js
Component.extend({
thingy: null
});
```
And an invocation like this:
```hbs
{{my-component thingy=(mut someValue)}}
```
(note that `mut` is the default for old-style component invocations)
In this case, because `my-component` has an explicit `thingy` property,
we set the property on rendering and re-rerendering for backwards
compatibility reasons.
Because `attrs.thingy` is a mutable cell, when we try to set `thingy` on
`my-component` during re-render, its `update` method is invoked, which
clobbers the original `someValue` unexpectedly. When `someValue` is a
computed property, the results can be catastrophic.
This commit avoids invoking `update` on a mutable cell in this
situation, avoiding this unnecessary cycle. | packages/ember-views/lib/views/states/default.js | @@ -1,10 +1,13 @@
import EmberError from "ember-metal/error";
+import { get } from "ember-metal/property_get";
import {
propertyWillChange,
propertyDidChange
} from "ember-metal/property_events";
+import { MUTABLE_CELL } from "ember-views/compat/attrs-proxy";
+
/**
@module ember
@submodule ember-views
@@ -35,6 +38,20 @@ export default {
}
},
+ legacyPropertyDidChange(view, key) {
+ let attrs = view.attrs;
+
+ if (attrs && key in attrs) {
+ let possibleCell = attrs[key];
+
+ if (possibleCell && possibleCell[MUTABLE_CELL]) {
+ let value = get(view, key);
+ if (value === possibleCell.value) { return; }
+ possibleCell.update(value);
+ }
+ }
+ },
+
// Handle events from `Ember.EventDispatcher`
handleEvent() {
return true; // continue event propagation | true |
Other | emberjs | ember.js | 5107da66e567895edb821d1440ba4e4cc5e5d4bb.json | Fix a cycle caused by legacy semantics
Consider a component like this:
```js
// my-component.js
Component.extend({
thingy: null
});
```
And an invocation like this:
```hbs
{{my-component thingy=(mut someValue)}}
```
(note that `mut` is the default for old-style component invocations)
In this case, because `my-component` has an explicit `thingy` property,
we set the property on rendering and re-rerendering for backwards
compatibility reasons.
Because `attrs.thingy` is a mutable cell, when we try to set `thingy` on
`my-component` during re-render, its `update` method is invoked, which
clobbers the original `someValue` unexpectedly. When `someValue` is a
computed property, the results can be catastrophic.
This commit avoids invoking `update` on a mutable cell in this
situation, avoiding this unnecessary cycle. | packages/ember-views/lib/views/states/pre_render.js | @@ -11,7 +11,8 @@ let preRender = create(_default);
merge(preRender, {
legacyAttrWillChange(view, key) {},
- legacyAttrDidChange(view, key) {}
+ legacyAttrDidChange(view, key) {},
+ legacyPropertyDidChange(view, key) {}
});
export default preRender; | true |
Other | emberjs | ember.js | 6069bb4e65e1272bb7d5d46307387c73ddb89775.json | Add empty tagName to avoid unnecessary div-tag
Fixes #11056 | packages/ember-htmlbars/tests/helpers/each_test.js | @@ -373,6 +373,31 @@ QUnit.test("it supports itemController", function() {
strictEqual(view.childViews[0].get('_arrayController.target'), parentController, "the target property of the child controllers are set correctly");
});
+QUnit.test("itemController should not affect the DOM structure", function() {
+ var Controller = EmberController.extend({
+ name: computed.alias('model.name')
+ });
+
+ runDestroy(view);
+
+ registry.register('controller:array', ArrayController.extend());
+
+ view = EmberView.create({
+ container: container,
+ template: templateFor(
+ '<div id="a">{{#each view.people itemController="person" as |person|}}{{person.name}}{{/each}}</div>' +
+ '<div id="b">{{#each view.people as |person|}}{{person.name}}{{/each}}</div>'
+ ),
+ people: people
+ });
+
+ registry.register('controller:person', Controller);
+
+ runAppend(view);
+
+ equal(view.$('#a').html(), view.$('#b').html());
+});
+
QUnit.test("itemController specified in template gets a parentController property", function() {
// using an ObjectController for this test to verify that parentController does accidentally get set
// on the proxied model. | true |
Other | emberjs | ember.js | 6069bb4e65e1272bb7d5d46307387c73ddb89775.json | Add empty tagName to avoid unnecessary div-tag
Fixes #11056 | packages/ember-views/lib/views/legacy_each_view.js | @@ -11,6 +11,7 @@ import { CONTAINER_MAP } from "ember-views/views/collection_view";
export default View.extend({
template: legacyEachTemplate,
+ tagName: '',
_arrayController: computed(function() {
var itemController = this.getAttr('itemController'); | true |
Other | emberjs | ember.js | 5014201d48e3777b7578b2d9e44619f92cad0eae.json | Restore hyphen requirement for component lookup. | packages/ember-application/tests/system/dependency_injection/custom_resolver_test.js | @@ -14,7 +14,11 @@ QUnit.module("Ember.Application Dependency Injection – customResolver", {
resolveTemplate(resolvable) {
var resolvedTemplate = this._super(resolvable);
if (resolvedTemplate) { return resolvedTemplate; }
- return fallbackTemplate;
+ if (resolvable.fullNameWithoutType === 'application') {
+ return fallbackTemplate;
+ } else {
+ return;
+ }
}
});
@@ -34,4 +38,3 @@ QUnit.module("Ember.Application Dependency Injection – customResolver", {
QUnit.test("a resolver can be supplied to application", function() {
equal(jQuery("h1", application.rootElement).text(), "Fallback");
});
- | true |
Other | emberjs | ember.js | 5014201d48e3777b7578b2d9e44619f92cad0eae.json | Restore hyphen requirement for component lookup. | packages/ember-htmlbars/tests/integration/component_lookup_test.js | @@ -0,0 +1,41 @@
+import EmberView from "ember-views/views/view";
+import Registry from "container/registry";
+import compile from "ember-template-compiler/system/compile";
+import ComponentLookup from 'ember-views/component_lookup';
+//import Component from "ember-views/views/component";
+import { runAppend, runDestroy } from "ember-runtime/tests/utils";
+
+var registry, container, view;
+
+QUnit.module('component - lookup', {
+ setup() {
+ registry = new Registry();
+ container = registry.container();
+ registry.optionsForType('component', { singleton: false });
+ registry.optionsForType('view', { singleton: false });
+ registry.optionsForType('template', { instantiate: false });
+ registry.optionsForType('helper', { instantiate: false });
+ registry.register('component-lookup:main', ComponentLookup);
+ },
+
+ teardown() {
+ runDestroy(container);
+ runDestroy(view);
+ registry = container = view = null;
+ }
+});
+
+QUnit.test('dashless components should not be found', function() {
+ expect(1);
+
+ registry.register('template:components/dashless', compile('Do not render me!'));
+
+ view = EmberView.extend({
+ template: compile('{{dashless}}'),
+ container: container
+ }).create();
+
+ expectAssertion(function() {
+ runAppend(view);
+ }, /You canot use 'dashless' as a component name. Component names must contain a hyphen./);
+}); | true |
Other | emberjs | ember.js | 5014201d48e3777b7578b2d9e44619f92cad0eae.json | Restore hyphen requirement for component lookup. | packages/ember-views/lib/component_lookup.js | @@ -1,6 +1,16 @@
+import Ember from 'ember-metal/core';
import EmberObject from "ember-runtime/system/object";
+import { ISNT_HELPER_CACHE } from "ember-htmlbars/system/lookup-helper";
export default EmberObject.extend({
+ invalidName(name) {
+ var invalidName = ISNT_HELPER_CACHE.get(name);
+
+ if (invalidName) {
+ Ember.assert(`You canot use '${name}' as a component name. Component names must contain a hyphen.`);
+ }
+ },
+
lookupFactory(name, container) {
container = container || this.container;
@@ -27,11 +37,19 @@ export default EmberObject.extend({
},
componentFor(name, container) {
+ if (this.invalidName(name)) {
+ return;
+ }
+
var fullName = 'component:' + name;
return container.lookupFactory(fullName);
},
layoutFor(name, container) {
+ if (this.invalidName(name)) {
+ return;
+ }
+
var templateFullName = 'template:components/' + name;
return container.lookup(templateFullName);
} | true |
Other | emberjs | ember.js | 6e63de48f3a94aa4ef3e76b484074807faa8df77.json | Allow bound outlet names
Bound outlet names actually work fine without any additional work. They
were just disallowed due to a very old assert that was introduced back
when we were first standardizing the use of quoted strings to represent
literals.
This drops the assertion and adds a test that shows bound outlet names
work. | packages/ember-htmlbars/lib/keywords/real_outlet.js | @@ -5,7 +5,6 @@
import { get } from "ember-metal/property_get";
import ComponentNode from "ember-htmlbars/system/component-node";
-import { isStream } from "ember-metal/streams/utils";
import topLevelViewTemplate from "ember-htmlbars/templates/top-level-view";
topLevelViewTemplate.revision = 'Ember@VERSION_STRING_PLACEHOLDER';
@@ -17,12 +16,6 @@ export default {
setupState(state, env, scope, params, hash) {
var outletState = env.outletState;
var read = env.hooks.getValue;
-
- Ember.assert(
- "Using {{outlet}} with an unquoted name is not supported.",
- !params[0] || !isStream(params[0])
- );
-
var outletName = read(params[0]) || 'main';
var selectedOutletState = outletState[outletName];
| true |
Other | emberjs | ember.js | 6e63de48f3a94aa4ef3e76b484074807faa8df77.json | Allow bound outlet names
Bound outlet names actually work fine without any additional work. They
were just disallowed due to a very old assert that was introduced back
when we were first standardizing the use of quoted strings to represent
literals.
This drops the assertion and adds a test that shows bound outlet names
work. | packages/ember-routing-htmlbars/tests/helpers/outlet_test.js | @@ -239,13 +239,49 @@ QUnit.test("should not throw deprecations if {{outlet}} is used with a quoted na
runAppend(top);
});
-QUnit.test("should throw an assertion if {{outlet}} used with unquoted name", function() {
- top.setOutletState(withTemplate("{{outlet foo}}"));
- expectAssertion(function() {
- runAppend(top);
- }, "Using {{outlet}} with an unquoted name is not supported.");
+QUnit.test("{{outlet}} should work with an unquoted name", function() {
+ var routerState = {
+ render: {
+ controller: Ember.Controller.create({
+ outletName: 'magical'
+ }),
+ template: compile('{{outlet outletName}}')
+ },
+ outlets: {
+ magical: withTemplate("It's magic")
+ }
+ };
+
+ top.setOutletState(routerState);
+ runAppend(top);
+
+ equal(top.$().text().trim(), "It's magic");
});
+QUnit.test("{{outlet}} should rerender when bound name changes", function() {
+ var routerState = {
+ render: {
+ controller: Ember.Controller.create({
+ outletName: 'magical'
+ }),
+ template: compile('{{outlet outletName}}')
+ },
+ outlets: {
+ magical: withTemplate("It's magic"),
+ second: withTemplate("second")
+ }
+ };
+
+ top.setOutletState(routerState);
+ runAppend(top);
+ equal(top.$().text().trim(), "It's magic");
+ run(function() {
+ routerState.render.controller.set('outletName', 'second');
+ });
+ equal(top.$().text().trim(), "second");
+});
+
+
function withTemplate(string) {
return {
render: { | true |
Other | emberjs | ember.js | ef926752426f99285e643d3286c034a2ccddcdb3.json | Prevent error when attributes are undefined/null. | packages/ember-views/lib/compat/attrs-proxy.js | @@ -82,7 +82,7 @@ AttrsProxyMixin[PROPERTY_DID_CHANGE] = function(key) {
if (attrs && key in attrs) {
let possibleCell = attrs[key];
- if (possibleCell[MUTABLE_CELL]) {
+ if (possibleCell && possibleCell[MUTABLE_CELL]) {
possibleCell.update(get(this, key));
}
} | true |
Other | emberjs | ember.js | ef926752426f99285e643d3286c034a2ccddcdb3.json | Prevent error when attributes are undefined/null. | packages/ember-views/tests/compat/attrs_proxy_test.js | @@ -2,6 +2,9 @@ import View from "ember-views/views/view";
import { runAppend, runDestroy } from "ember-runtime/tests/utils";
import compile from "ember-template-compiler/system/compile";
import Registry from "container/registry";
+import run from "ember-metal/run_loop";
+import { set } from "ember-metal/property_set";
+import { get } from "ember-metal/property_get";
var view, registry, container;
@@ -32,3 +35,34 @@ QUnit.test('works with properties setup in root of view', function() {
equal(view.$().text(), 'baz', 'value specified in the template is used');
});
+
+QUnit.test('works with undefined attributes', function() {
+ expectDeprecation();
+
+ var childView;
+ registry.register('view:foo', View.extend({
+ init: function() {
+ this._super(...arguments);
+
+ childView = this;
+ },
+
+ template: compile('{{bar}}')
+ }));
+
+ view = View.extend({
+ container: registry.container(),
+
+ template: compile('{{view "foo" bar=undefined}}')
+ }).create();
+
+ runAppend(view);
+
+ equal(view.$().text(), '', 'precond - value is used');
+
+ run(function() {
+ set(childView, 'bar', 'stuff');
+ });
+
+ equal(get(view, 'bar'), undefined, 'value is updated upstream');
+}); | true |
Other | emberjs | ember.js | 4d177cafd5943d3d7937945abfe392716f237d73.json | Remove dead code | packages/ember-htmlbars/lib/system/shadow-root.js | @@ -1,38 +0,0 @@
-import { internal } from "htmlbars-runtime";
-
-/** @private
- A ShadowRoot represents a new root scope. However, it
- is not a render tree root.
-*/
-
-function ShadowRoot(layoutMorph, layoutTemplate, contentScope, contentTemplate) {
- this.layoutMorph = layoutMorph;
- this.layoutTemplate = layoutTemplate;
-
- this.contentScope = contentScope;
- this.contentTemplate = contentTemplate;
-}
-
-ShadowRoot.prototype.render = function(env, self, shadowOptions, visitor) {
- if (!this.layoutTemplate && !this.contentTemplate) { return; }
-
- shadowOptions.attrs = self.attrs;
-
- var shadowRoot = this;
-
- 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) {
- return this.layoutTemplate === layout &&
- this.contentTemplate === template;
-};
-
-export default ShadowRoot; | false |
Other | emberjs | ember.js | 12b249632c4047c312441b69a7d51584595141dc.json | Allow publishing of idempotent-rerender PR to S3. | bin/publish_builds | @@ -3,7 +3,7 @@
echo -e "CURRENT_BRANCH: ${TRAVIS_BRANCH}\n"
echo -e "PULL_REQUEST: ${TRAVIS_PULL_REQUEST}\n"
-if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
+if [ "$TRAVIS_PULL_REQUEST" == "false" ] || [ "$TRAVIS_PULL_REQUEST" == "10501" ]; then
if [ "$EMBER_ENV" != "production" ]; then
DISABLE_JSCS=true DISABLE_JSHINT=true ember build --environment=production | false |
Other | emberjs | ember.js | a233059b52fa865eac093f6076bf8736d49afe18.json | Publish Glimmer builds to S3.
Make testing apps easier... | config/s3ProjectConfig.js | @@ -18,6 +18,10 @@ function fileObject(baseName, extension, contentType, currentRevision, tag, date
var obj = {
contentType: contentType,
destinations: {
+ glimmer: [
+ "glimmer" + fullName,
+ "canary/shas/" + currentRevision + fullName
+ ],
canary: [
"latest" + fullName,
"canary" + fullName, | false |
Other | emberjs | ember.js | d9e5c8018fad8a1ddab2e5f1f2ddd61975ef08c1.json | Unskip mutable binding test. | packages/ember-htmlbars/tests/integration/mutable_binding_test.js | @@ -87,7 +87,7 @@ QUnit.test('a simple mutable binding using `mut` propagates properly', function(
assert.strictEqual(view.get('val'), 13, "the set propagated back up");
});
-QUnit.skip('using a string value through middle tier does not trigger assertion', function(assert) {
+QUnit.test('using a string value through middle tier does not trigger assertion', function(assert) {
var bottom;
registry.register('component:middle-mut', Component.extend({ | false |
Other | emberjs | ember.js | 27a6c57b0d15766b65a8ae1f74e1ab37e3493add.json | Intercept property changes instead of sets
(cherry picked from commit b4d53bfd2d2769c4133f5f55e5551c6cc2dc87f8) | packages/ember-htmlbars/tests/integration/select_in_template_test.js | @@ -239,7 +239,7 @@ function testValueBinding(templateString) {
equal(selectEl.selectedIndex, 1, "The DOM is updated to reflect the new selection");
}
-QUnit.skip("select element should correctly initialize and update selectedIndex and bound properties when using valueBinding [DEPRECATED]", function() {
+QUnit.test("select element should correctly initialize and update selectedIndex and bound properties when using valueBinding [DEPRECATED]", function() {
expectDeprecation(`You're using legacy binding syntax: valueBinding="view.val" @ 1:176 in (inline). Please replace with value=view.val`);
testValueBinding(
@@ -252,7 +252,7 @@ QUnit.skip("select element should correctly initialize and update selectedIndex
);
});
-QUnit.skip("select element should correctly initialize and update selectedIndex and bound properties when using valueBinding", function() {
+QUnit.test("select element should correctly initialize and update selectedIndex and bound properties when using valueBinding", function() {
testValueBinding(
'{{view view.selectView viewName="select"' +
' content=view.collection' + | true |
Other | emberjs | ember.js | 27a6c57b0d15766b65a8ae1f74e1ab37e3493add.json | Intercept property changes instead of sets
(cherry picked from commit b4d53bfd2d2769c4133f5f55e5551c6cc2dc87f8) | packages/ember-metal/lib/property_events.js | @@ -7,6 +7,9 @@ import {
accumulateListeners
} from "ember-metal/events";
import ObserverSet from "ember-metal/observer_set";
+import { symbol } from "ember-metal/utils";
+
+export let PROPERTY_DID_CHANGE = symbol("PROPERTY_DID_CHANGE");
var beforeObserverSet = new ObserverSet();
var observerSet = new ObserverSet();
@@ -86,6 +89,10 @@ function propertyDidChange(obj, keyName) {
desc.didChange(obj, keyName);
}
+ if (obj[PROPERTY_DID_CHANGE]) {
+ obj[PROPERTY_DID_CHANGE](keyName);
+ }
+
if (!watching && keyName !== 'length') {
return;
} | true |
Other | emberjs | ember.js | 27a6c57b0d15766b65a8ae1f74e1ab37e3493add.json | Intercept property changes instead of sets
(cherry picked from commit b4d53bfd2d2769c4133f5f55e5551c6cc2dc87f8) | packages/ember-metal/lib/property_set.js | @@ -1,6 +1,7 @@
import Ember from "ember-metal/core";
import { _getPath as getPath } from "ember-metal/property_get";
import {
+ PROPERTY_DID_CHANGE,
propertyWillChange,
propertyDidChange
} from "ember-metal/property_events";
@@ -116,6 +117,9 @@ export function set(obj, keyName, value, tolerant) {
}
} else {
obj[keyName] = value;
+ if (obj[PROPERTY_DID_CHANGE]) {
+ obj[PROPERTY_DID_CHANGE](keyName);
+ }
}
}
return value; | true |
Other | emberjs | ember.js | 27a6c57b0d15766b65a8ae1f74e1ab37e3493add.json | Intercept property changes instead of sets
(cherry picked from commit b4d53bfd2d2769c4133f5f55e5551c6cc2dc87f8) | packages/ember-views/lib/compat/attrs-proxy.js | @@ -4,7 +4,7 @@ import { Mixin } from "ember-metal/mixin";
import { on } from "ember-metal/events";
import { symbol } from "ember-metal/utils";
import objectKeys from "ember-metal/keys";
-import { INTERCEPT_SET, UNHANDLED_SET } from 'ember-metal/property_set';
+import { PROPERTY_DID_CHANGE } from "ember-metal/property_events";
//import run from "ember-metal/run_loop";
export function deprecation(key) {
@@ -76,31 +76,16 @@ let AttrsProxyMixin = {
//}
};
-AttrsProxyMixin[INTERCEPT_SET] = function(obj, key, value) {
- let attrs = obj.attrs;
+AttrsProxyMixin[PROPERTY_DID_CHANGE] = function(key) {
+ let attrs = this.attrs;
- if (key === 'attrs') { return UNHANDLED_SET; }
- if (!attrs || !(key in attrs)) {
- return UNHANDLED_SET;
- }
-
- let possibleCell = attrs[key];
-
- if (!possibleCell[MUTABLE_CELL]) {
- return UNHANDLED_SET;
- // This would ideally be an error, but there are cases where immutable
- // data from attrs is copied into local state, setting that
- // state is legitimate.
- //throw new Error(`You cannot set ${key} because attrs.${key} is not mutable`);
- }
+ if (attrs && key in attrs) {
+ let possibleCell = attrs[key];
- possibleCell.update(value);
-
- if (key in obj) {
- return UNHANDLED_SET;
+ if (possibleCell[MUTABLE_CELL]) {
+ possibleCell.update(get(this, key));
+ }
}
-
- return value;
};
export default Mixin.create(AttrsProxyMixin); | true |
Other | emberjs | ember.js | 27a6c57b0d15766b65a8ae1f74e1ab37e3493add.json | Intercept property changes instead of sets
(cherry picked from commit b4d53bfd2d2769c4133f5f55e5551c6cc2dc87f8) | packages/ember-views/tests/views/view_test.js | @@ -124,7 +124,7 @@ QUnit.test("propagates dependent-key invalidated sets upstream", function() {
equal(view.get('parentProp'), 'new-value', 'new value is propagated across template');
});
-QUnit.skip("propagates dependent-key invalidated bindings upstream", function() {
+QUnit.test("propagates dependent-key invalidated bindings upstream", function() {
view = EmberView.create({
parentProp: 'parent-value',
template: compile("{{view view.childView childProp=view.parentProp}}"),
@@ -147,7 +147,7 @@ QUnit.skip("propagates dependent-key invalidated bindings upstream", function()
equal(view.get('parentProp'), 'parent-value', 'precond - parent value is there');
var childView = view.get('childView');
- childView.set('dependencyProp', 'new-value');
+ run(() => childView.set('dependencyProp', 'new-value'));
equal(childView.get('childProp'), 'new-value', 'pre-cond - new value is propagated to CP');
equal(view.get('parentProp'), 'new-value', 'new value is propagated across template');
}); | true |
Other | emberjs | ember.js | 4cfb2bdb32b3df7df460ab1e20e9bb6592239298.json | Fix controller local w/ `{{#each itemController}}` | packages/ember-htmlbars/lib/helpers/-legacy-each-with-controller.js | @@ -14,19 +14,25 @@ export default function legacyEachWithControllerHelper(params, hash, blocks) {
forEach(list, function(item, i) {
var self;
+
if (blocks.template.arity === 0) {
Ember.deprecate(deprecation);
self = normalizeSelf(item);
- self = {
- self: self,
- hasBoundController: true
- };
+ self = bindController(self, true);
}
var key = keyPath ? get(item, keyPath) : String(i);
blocks.template.yieldItem(key, [item, i], self);
});
}
+function bindController(controller, isSelf) {
+ return {
+ controller: controller,
+ hasBoundController: true,
+ self: controller ? controller : undefined
+ };
+}
+
export var deprecation = "Using the context switching form of {{each}} is deprecated. Please use the keyword form (`{{#each items as |item|}}`) instead.";
| true |
Other | emberjs | ember.js | 4cfb2bdb32b3df7df460ab1e20e9bb6592239298.json | Fix controller local w/ `{{#each itemController}}` | packages/ember-htmlbars/lib/hooks/bind-shadow-scope.js | @@ -8,10 +8,20 @@ import Component from 'ember-views/views/component';
export default function bindShadowScope(env, parentScope, shadowScope, options) {
if (!options) { return; }
+ let didOverrideController = false;
+
+ if (parentScope && parentScope.overrideController) {
+ didOverrideController = true;
+ shadowScope.locals.controller = parentScope.locals.controller;
+ }
+
var view = options.view;
if (view && !(view instanceof Component)) {
newStream(shadowScope.locals, 'view', view, null);
- newStream(shadowScope.locals, 'controller', shadowScope.locals.view.getKey('controller'));
+
+ if (!didOverrideController) {
+ newStream(shadowScope.locals, 'controller', shadowScope.locals.view.getKey('controller'));
+ }
if (view.isView) {
newStream(shadowScope, 'self', shadowScope.locals.view.getKey('context'), null, true); | true |
Other | emberjs | ember.js | 4cfb2bdb32b3df7df460ab1e20e9bb6592239298.json | Fix controller local w/ `{{#each itemController}}` | packages/ember-htmlbars/lib/keywords/legacy-yield.js | @@ -1,5 +1,19 @@
-export default function legacyYield(morph, env, scope, params, hash, template, inverse, visitor) {
+import ProxyStream from "ember-metal/streams/proxy-stream";
+
+export default function legacyYield(morph, env, _scope, params, hash, template, inverse, visitor) {
+ let scope = _scope;
+
if (scope.block.arity === 0) {
+ // Typically, the `controller` local is persists through lexical scope.
+ // However, in this case, the `{{legacy-yield}}` in the legacy each view
+ // needs to override the controller local for the template it is yielding.
+ // This megahaxx allows us to override the controller, and most importantly,
+ // prevents the downstream scope from attempting to bind the `controller` local.
+ if (hash.controller) {
+ scope = env.hooks.createChildScope(scope);
+ scope.locals.controller = new ProxyStream(hash.controller, "controller");
+ scope.overrideController = true;
+ }
scope.block(env, [], params[0], morph, scope, visitor);
} else {
scope.block(env, params, undefined, morph, scope, visitor); | true |
Other | emberjs | ember.js | 4cfb2bdb32b3df7df460ab1e20e9bb6592239298.json | Fix controller local w/ `{{#each itemController}}` | packages/ember-htmlbars/lib/templates/legacy-each.hbs | @@ -1 +1 @@
-{{~#each view._arrangedContent as |item|}}{{#if attrs.itemViewClass}}{{#view attrs.itemViewClass controller=item tagName=view._itemTagName}}{{legacy-yield item}}{{/view}}{{else}}{{legacy-yield item}}{{/if}}{{else if attrs.emptyViewClass}}{{view attrs.emptyViewClass tagName=view._itemTagName}}{{/each~}}
+{{~#each view._arrangedContent as |item|}}{{#if attrs.itemViewClass}}{{#view attrs.itemViewClass controller=item tagName=view._itemTagName}}{{legacy-yield item}}{{/view}}{{else}}{{legacy-yield item controller=item}}{{/if}}{{else if attrs.emptyViewClass}}{{view attrs.emptyViewClass tagName=view._itemTagName}}{{/each~}} | true |
Other | emberjs | ember.js | 4cfb2bdb32b3df7df460ab1e20e9bb6592239298.json | Fix controller local w/ `{{#each itemController}}` | packages/ember/tests/controller_test.js | @@ -71,7 +71,7 @@ QUnit.test("Actions inside an outlet go to the associated controller", function(
// This test caught a regression where {{#each}}s used directly in a template
// (i.e., not inside a view or component) did not have access to a container and
// would raise an exception.
-QUnit.test("{{#each}} inside outlet can have an itemController", function() {
+QUnit.test("{{#each}} inside outlet can have an itemController", function(assert) {
templates.index = compile(`
{{#each model itemController='thing'}}
<p>hi</p>
@@ -86,7 +86,38 @@ QUnit.test("{{#each}} inside outlet can have an itemController", function() {
bootApp();
- equal($fixture.find('p').length, 3, "the {{#each}} rendered without raising an exception");
+ assert.equal($fixture.find('p').length, 3, "the {{#each}} rendered without raising an exception");
+});
+
+QUnit.test("", function(assert) {
+ templates.index = compile(`
+ {{#each model itemController='thing'}}
+ {{controller}}
+ <p><a {{action 'checkController' controller}}>Click me</a></p>
+ {{/each}}
+ `);
+
+ App.IndexRoute = Ember.Route.extend({
+ model: function() {
+ return Ember.A([
+ {name: 'red'},
+ {name: 'yellow'},
+ {name: 'blue'}
+ ]);
+ }
+ });
+
+ App.ThingController = Ember.Controller.extend({
+ actions: {
+ checkController: function(controller) {
+ assert.ok(controller === this, "correct controller was passed as action context");
+ }
+ }
+ });
+
+ bootApp();
+
+ $fixture.find('a').first().click();
});
function bootApp() { | true |
Other | emberjs | ember.js | 5a33e9c00b025152e3ed30981f245738c02fd52c.json | Propagate controller keyword for outlets | packages/ember-htmlbars/lib/hooks/bind-self.js | @@ -25,6 +25,10 @@ export default function bindSelf(env, scope, _self) {
}
newStream(scope, 'self', self, null, true);
+
+ if (!scope.locals.controller) {
+ scope.locals.controller = scope.self;
+ }
}
function newStream(scope, key, newValue, renderNode, isSelf) { | true |
Other | emberjs | ember.js | 5a33e9c00b025152e3ed30981f245738c02fd52c.json | Propagate controller keyword for outlets | packages/ember-htmlbars/lib/node-managers/component-node-manager.js | @@ -57,7 +57,11 @@ ComponentNodeManager.create = function(renderNode, env, options) {
if (attrs.viewName) { createOptions.viewName = getValue(attrs.viewName); }
if (component.create && parentScope && parentScope.self) {
- options._context = getValue(parentScope.self);
+ createOptions._context = getValue(parentScope.self);
+ }
+
+ if (parentScope.locals.controller) {
+ createOptions._controller = getValue(parentScope.locals.controller);
}
component = createOrUpdateComponent(component, createOptions, renderNode, env, attrs); | true |
Other | emberjs | ember.js | 5a33e9c00b025152e3ed30981f245738c02fd52c.json | Propagate controller keyword for outlets | packages/ember-views/lib/views/component.js | @@ -172,6 +172,7 @@ var Component = View.extend(TargetActionSupport, ComponentTemplateDeprecation, {
@default null
*/
targetObject: computed('parentView', function(key) {
+ if (this._controller) { return this._controller; }
var parentView = get(this, 'parentView');
return parentView ? get(parentView, 'controller') : null;
}), | true |
Other | emberjs | ember.js | 5a33e9c00b025152e3ed30981f245738c02fd52c.json | Propagate controller keyword for outlets | packages/ember/tests/helpers/link_to_test.js | @@ -1024,7 +1024,7 @@ QUnit.test("The non-block form {{link-to}} helper updates the link text when it
equal(Ember.$('#contact-link:contains(Robert)', '#qunit-fixture').length, 1, "The link title is correctly updated when the route changes");
});
-QUnit.skip("The non-block form {{link-to}} helper moves into the named route with context", function() {
+QUnit.test("The non-block form {{link-to}} helper moves into the named route with context", function() {
expect(5);
Router.map(function(match) {
this.route("item", { path: "/item/:id" }); | true |
Other | emberjs | ember.js | 5a33e9c00b025152e3ed30981f245738c02fd52c.json | Propagate controller keyword for outlets | packages/ember/tests/template_scope_test.js | @@ -35,7 +35,7 @@ QUnit.module("Template scoping examples", {
}
});
-QUnit.skip("Actions inside an outlet go to the associated controller", function() {
+QUnit.test("Actions inside an outlet go to the associated controller", function() {
expect(1);
templates.index = compile("{{component-with-action action='componentAction'}}"); | true |
Other | emberjs | ember.js | 73881e41290eb86850193fb34e085d7e46c53641.json | Fix dynamic `makeViewHelper`. | packages/ember-htmlbars/tests/system/make_view_helper_test.js | @@ -53,7 +53,6 @@ QUnit.test("can properly yield", function() {
});
runAppend(view);
- debugger
equal(view.$().text(), 'Some Random Class - Template');
}); | false |
Other | emberjs | ember.js | 57f05daa8fc4fd94e3507e4dab2bcbab3e32f699.json | Fix dynamic `makeViewHelper`. | package.json | @@ -23,7 +23,7 @@
"express": "^4.5.0",
"github": "^0.2.3",
"glob": "~4.3.2",
- "htmlbars": "0.13.11",
+ "htmlbars": "0.13.12",
"qunit-extras": "^1.3.0",
"qunitjs": "^1.16.0",
"route-recognizer": "0.1.5", | true |
Other | emberjs | ember.js | 57f05daa8fc4fd94e3507e4dab2bcbab3e32f699.json | Fix dynamic `makeViewHelper`. | packages/ember-htmlbars/lib/helpers.js | @@ -3,9 +3,7 @@
@submodule ember-htmlbars
*/
-import Ember from 'ember-metal/core'; // Ember.assert
import o_create from "ember-metal/platform/create";
-import { registerKeyword } from "ember-htmlbars/keywords";
/**
@private
@@ -26,17 +24,6 @@ var helpers = o_create(null);
@param {Object|Function} helperFunc the helper function to add
*/
export function registerHelper(name, helperFunc) {
- if (helperFunc.isLegacyViewHelper) {
- registerKeyword(name, function(morph, env, scope, params, hash, template, inverse, visitor) {
- Ember.assert("You can only pass attributes (such as name=value) not bare " +
- "values to a helper for a View found in '" + helperFunc.viewClass + "'", params.length === 0);
-
- env.hooks.keyword('view', morph, env, scope, [helperFunc.viewClass], hash, template, inverse, visitor);
- return true;
- });
- return;
- }
-
helpers[name] = helperFunc;
}
| true |
Other | emberjs | ember.js | 57f05daa8fc4fd94e3507e4dab2bcbab3e32f699.json | Fix dynamic `makeViewHelper`. | packages/ember-htmlbars/lib/hooks/invoke-helper.js | @@ -1,12 +1,21 @@
+import Ember from 'ember-metal/core'; // Ember.assert
import getValue from "ember-htmlbars/hooks/get-value";
+
+
export default function invokeHelper(morph, env, scope, visitor, _params, _hash, helper, templates, context) {
var params, hash;
if (typeof helper === 'function') {
params = getArrayValues(_params);
hash = getHashValues(_hash);
return { value: helper.call(context, params, hash, templates) };
+ } else if (helper.isLegacyViewHelper) {
+ Ember.assert("You can only pass attributes (such as name=value) not bare " +
+ "values to a helper for a View found in '" + helper.viewClass + "'", _params.length === 0);
+
+ env.hooks.keyword('view', morph, env, scope, [helper.viewClass], _hash, templates.template.raw, null, visitor);
+ return { handled: true };
} else if (helper && helper.helperFunction) {
var helperFunc = helper.helperFunction;
return { value: helperFunc.call({}, _params, _hash, templates, env, scope) }; | true |
Other | emberjs | ember.js | 57f05daa8fc4fd94e3507e4dab2bcbab3e32f699.json | Fix dynamic `makeViewHelper`. | packages/ember-htmlbars/tests/system/make_view_helper_test.js | @@ -17,11 +17,15 @@ QUnit.module("ember-htmlbars: makeViewHelper", {
}
});
-QUnit.skip("makes helpful assertion when called with invalid arguments", function() {
+QUnit.test("makes helpful assertion when called with invalid arguments", function() {
var SomeRandom = EmberView.extend({
template: compile("Some Random Class")
});
+ SomeRandom.toString = function() {
+ return 'Some Random Class';
+ };
+
var helper = makeViewHelper(SomeRandom);
registry.register('helper:some-random', helper);
@@ -34,3 +38,22 @@ QUnit.skip("makes helpful assertion when called with invalid arguments", functio
runAppend(view);
}, "You can only pass attributes (such as name=value) not bare values to a helper for a View found in 'Some Random Class'");
});
+
+QUnit.test("can properly yield", function() {
+ var SomeRandom = EmberView.extend({
+ layout: compile("Some Random Class - {{yield}}")
+ });
+
+ var helper = makeViewHelper(SomeRandom);
+ registry.register('helper:some-random', helper);
+
+ view = EmberView.create({
+ template: compile("{{#some-random}}Template{{/some-random}}"),
+ container
+ });
+
+ runAppend(view);
+ debugger
+
+ equal(view.$().text(), 'Some Random Class - Template');
+}); | true |
Other | emberjs | ember.js | 57f05daa8fc4fd94e3507e4dab2bcbab3e32f699.json | Fix dynamic `makeViewHelper`. | packages/ember/tests/helpers/helper_registration_test.js | @@ -84,7 +84,7 @@ QUnit.test("Bound helpers registered on the container can be late-invoked", func
ok(!helpers['x-reverse'], "Container-registered helper doesn't wind up on global helpers hash");
});
-QUnit.skip("Bound `makeViewHelper` helpers registered on the container can be used", function() {
+QUnit.test("Bound `makeViewHelper` helpers registered on the container can be used", function() {
Ember.TEMPLATES.application = compile("<div id='wrapper'>{{x-foo}} {{x-foo name=foo}}</div>");
boot(function() {
@@ -93,7 +93,7 @@ QUnit.skip("Bound `makeViewHelper` helpers registered on the container can be us
}));
registry.register('helper:x-foo', makeViewHelper(Ember.Component.extend({
- layout: compile('woot!!{{name}}')
+ layout: compile('woot!!{{attrs.name}}')
})));
});
| true |
Other | emberjs | ember.js | 2d501df08085018bcab80148ce941ce4410a6c03.json | Remove unused imports in Ember.TextArea. | packages/ember-views/lib/views/text_area.js | @@ -2,10 +2,8 @@
@module ember
@submodule ember-views
*/
-import { get } from "ember-metal/property_get";
import Component from "ember-views/views/component";
import TextSupport from "ember-views/mixins/text_support";
-import { observer } from "ember-metal/mixin";
/**
The internal class used to create textarea element when the `{{textarea}}` | false |
Other | emberjs | ember.js | 0e674a4eb9e08ad98909db8de78b89e505114405.json | Update HTMLBars to v0.13.11.
* Remove 'value' attribute hacks.
* Add `AttrMorph.prototype.getContent`. | package.json | @@ -23,7 +23,7 @@
"express": "^4.5.0",
"github": "^0.2.3",
"glob": "~4.3.2",
- "htmlbars": "0.13.10",
+ "htmlbars": "0.13.11",
"qunit-extras": "^1.3.0",
"qunitjs": "^1.16.0",
"route-recognizer": "0.1.5", | false |
Other | emberjs | ember.js | a80574534bf0ec76d34ac3cdbc956df03c2fe183.json | Use readDOMAttr + attributeBinding for <textarea>.
The new `readDOMAttr` API allows us to remove this manual `value`
property binding in `Ember.TextArea`. | packages/ember-views/lib/views/text_area.js | @@ -1,4 +1,3 @@
-
/**
@module ember
@submodule ember-views
@@ -39,22 +38,9 @@ export default Component.extend(TextSupport, {
'selectionStart',
'wrap',
'lang',
- 'dir'
+ 'dir',
+ 'value'
],
rows: null,
- cols: null,
-
- _updateElementValue: observer('value', function() {
- // We do this check so cursor position doesn't get affected in IE
- var value = get(this, 'value');
- var $el = this.$();
- if ($el && value !== $el.val()) {
- $el.val(value);
- }
- }),
-
- init() {
- this._super(...arguments);
- this.on("didInsertElement", this, this._updateElementValue);
- }
+ cols: null
}); | true |
Other | emberjs | ember.js | a80574534bf0ec76d34ac3cdbc956df03c2fe183.json | Use readDOMAttr + attributeBinding for <textarea>.
The new `readDOMAttr` API allows us to remove this manual `value`
property binding in `Ember.TextArea`. | packages/ember-views/tests/views/text_area_test.js | @@ -186,9 +186,11 @@ forEach.call(['cut', 'paste', 'input'], function(eventName) {
});
textArea.$().val('new value');
- textArea.trigger(eventName, EmberObject.create({
- type: eventName
- }));
+ run(function() {
+ textArea.trigger(eventName, EmberObject.create({
+ type: eventName
+ }));
+ });
equal(textArea.get('value'), 'new value', 'value property updates on ' + eventName + ' events');
}); | true |
Other | emberjs | ember.js | 4e585da9dc2882e6babd11499acad6e450805eb9.json | Fix issue with inputs getting re-rendered | packages/ember-htmlbars/lib/keywords/input.js | @@ -1,4 +1,5 @@
import Ember from "ember-metal/core";
+import { assign } from "ember-metal/merge";
export default {
setupState(lastState, env, scope, params, hash) {
@@ -8,7 +9,7 @@ export default {
Ember.assert("{{input type='checkbox'}} does not support setting `value=someBooleanValue`;" +
" you must use `checked=someBooleanValue` instead.", !(type === 'checkbox' && hash.hasOwnProperty('value')));
- return { componentName };
+ return assign({}, lastState, { componentName });
},
render(morph, env, scope, params, hash, template, inverse, visitor) { | true |
Other | emberjs | ember.js | 4e585da9dc2882e6babd11499acad6e450805eb9.json | Fix issue with inputs getting re-rendered | packages/ember-htmlbars/tests/helpers/input_test.js | @@ -62,8 +62,13 @@ QUnit.test("should become disabled if the disabled attribute is true", function(
QUnit.test("input value is updated when setting value property of view", function() {
equal(view.$('input').val(), "hello", "renders text field with value");
+
+ let id = view.$('input').prop('id');
+
run(null, set, controller, 'val', 'bye!');
equal(view.$('input').val(), "bye!", "updates text field after value changes");
+
+ equal(view.$('input').prop('id'), id, "the component hasn't changed");
});
QUnit.test("input placeholder is updated when setting placeholder property of view", function() { | true |
Other | emberjs | ember.js | 4e585da9dc2882e6babd11499acad6e450805eb9.json | Fix issue with inputs getting re-rendered | packages/ember-metal/lib/merge.js | @@ -32,3 +32,16 @@ export default function merge(original, updates) {
return original;
}
+
+export function assign(original, ...args) {
+ for (let i=0, l=args.length; i<l; i++) {
+ let arg = args[i];
+ if (!arg) { continue; }
+
+ for (let prop in arg) {
+ if (arg.hasOwnProperty(prop)) { original[prop] = arg[prop]; }
+ }
+ }
+
+ return original;
+} | true |
Other | emberjs | ember.js | 37b21bf917ac00fe70ace5c6a37419f2110b583a.json | Remove vestigial `states.changingKeys` | packages/ember-routing/lib/system/route.js | @@ -147,9 +147,6 @@ var Route = EmberObject.extend(ActionHandler, Evented, {
},
allowOverrides: (controller, prop) => {
return this._updatingQPChanged(controller, map[prop]);
- },
- changingKeys: (controller, prop) => {
- return this._updateSerializedQPValue(controller, map[prop]);
}
}
};
@@ -1096,7 +1093,6 @@ var Route = EmberObject.extend(ActionHandler, Evented, {
if (transition) {
// Update the model dep values used to calculate cache keys.
stashParamNames(this.router, transition.state.handlerInfos);
- controller._qpDelegate = states.changingKeys;
controller._updateCacheParams(transition.params);
}
controller._qpDelegate = states.allowOverrides; | false |
Other | emberjs | ember.js | ce28b3ca811e520e86de8caa8a632fab58c6c4bf.json | Notify view controller when its parentView changes | packages/ember-views/lib/mixins/view_context_support.js | @@ -8,6 +8,7 @@ import { get } from "ember-metal/property_get";
import { set } from "ember-metal/property_set";
import LegacyViewSupport from "ember-views/mixins/legacy_view_support";
import { observer } from "ember-metal/mixin";
+import { on } from "ember-metal/events";
var ViewContextSupport = Mixin.create(LegacyViewSupport, {
/**
@@ -94,6 +95,10 @@ var ViewContextSupport = Mixin.create(LegacyViewSupport, {
_legacyControllerDidChange: observer('controller', function() {
this.walkChildViews(view => view.notifyPropertyChange('controller'));
+ }),
+
+ _notifyControllerChange: on('parentViewDidChange', function() {
+ this.notifyPropertyChange('controller');
})
});
| true |
Other | emberjs | ember.js | ce28b3ca811e520e86de8caa8a632fab58c6c4bf.json | Notify view controller when its parentView changes | packages/ember-views/tests/views/view/controller_test.js | @@ -4,7 +4,7 @@ import ContainerView from "ember-views/views/container_view";
QUnit.module("Ember.View - controller property");
-QUnit.skip("controller property should be inherited from nearest ancestor with controller", function() {
+QUnit.test("controller property should be inherited from nearest ancestor with controller", function() {
var grandparent = ContainerView.create();
var parent = ContainerView.create();
var child = ContainerView.create(); | true |
Other | emberjs | ember.js | dc97966be2134d794611b0c693193caad8207dc0.json | Preserve controller instance across rerenders | packages/ember-htmlbars/lib/keywords/with.js | @@ -5,19 +5,23 @@ export default {
setupState(state, env, scope, params, hash) {
var controller = hash.controller;
- if (controller && !state.controller) {
- var context = params[0];
- var controllerFactory = env.container.lookupFactory('controller:' + controller);
- var parentController = scope.view ? get(scope.view, 'context') : null;
-
- var controllerInstance = controllerFactory.create({
- model: env.hooks.getValue(context),
- parentController: parentController,
- target: parentController
- });
-
- params[0] = controllerInstance;
- return { controller: controllerInstance };
+ if (controller) {
+ if (!state.controller) {
+ var context = params[0];
+ var controllerFactory = env.container.lookupFactory('controller:' + controller);
+ var parentController = scope.view ? get(scope.view, 'context') : null;
+
+ var controllerInstance = controllerFactory.create({
+ model: env.hooks.getValue(context),
+ parentController: parentController,
+ target: parentController
+ });
+
+ params[0] = controllerInstance;
+ return { controller: controllerInstance };
+ }
+
+ return state;
}
return { controller: null }; | true |
Other | emberjs | ember.js | dc97966be2134d794611b0c693193caad8207dc0.json | Preserve controller instance across rerenders | packages/ember-htmlbars/tests/helpers/with_test.js | @@ -226,7 +226,7 @@ QUnit.test("it should support #with this as qux", function() {
QUnit.module("Handlebars {{#with foo}} with defined controller");
-QUnit.skip("it should wrap context with object controller [DEPRECATED]", function() {
+QUnit.test("it should wrap context with object controller [DEPRECATED]", function() {
var childController;
var Controller = ObjectController.extend({
@@ -259,9 +259,9 @@ QUnit.skip("it should wrap context with object controller [DEPRECATED]", functio
registry.register('controller:person', Controller);
expectDeprecation(objectControllerDeprecation);
- expectDeprecation(function() {
- runAppend(view);
- }, 'Using the context switching form of `{{with}}` is deprecated. Please use the block param form (`{{#with bar as |foo|}}`) instead.');
+ expectDeprecation('Using the context switching form of `{{with}}` is deprecated. Please use the block param form (`{{#with bar as |foo|}}`) instead.');
+
+ runAppend(view);
equal(view.$().text(), "controller:Steve Holt and Bob Loblaw");
| true |
Other | emberjs | ember.js | a2d9a41354d40c2737a64c94308bd488562fd713.json | Fix incorrect `typeOf` import.
`typeOf` moved from `ember-metal/utils` to `ember-runtime/utils` as of
https://github.com/emberjs/ember.js/pull/10988. | packages/ember-views/lib/views/core_view.js | @@ -10,7 +10,7 @@ import ActionHandler from "ember-runtime/mixins/action_handler";
import { get } from "ember-metal/property_get";
-import { typeOf } from "ember-metal/utils";
+import { typeOf } from "ember-runtime/utils";
import { internal } from "htmlbars-runtime";
function K() { return this; } | false |
Other | emberjs | ember.js | 53e6ebaeff50de9265cff4bfacf6611ac9576b19.json | Fix lint errors.
* `get` was unused in ember-routing-htmlbars/keywords/action
* Indentation was incorrect in ember-htmlbars/tests/integration/mutable_binding_test | packages/ember-htmlbars/tests/integration/mutable_binding_test.js | @@ -189,6 +189,7 @@ QUnit.test('a simple mutable binding using `mut` is available in hooks', functio
assert.strictEqual(view.get('val'), 13, "the set propagated back up");
});
+// jscs:disable validateIndentation
if (Ember.FEATURES.isEnabled('ember-htmlbars-component-generation')) {
QUnit.test('mutable bindings work as angle-bracket component attributes', function(assert) {
@@ -225,3 +226,4 @@ QUnit.test('mutable bindings work as angle-bracket component attributes', functi
});
}
+// jscs:enable validateIndentation | true |
Other | emberjs | ember.js | 53e6ebaeff50de9265cff4bfacf6611ac9576b19.json | Fix lint errors.
* `get` was unused in ember-routing-htmlbars/keywords/action
* Indentation was incorrect in ember-htmlbars/tests/integration/mutable_binding_test | packages/ember-routing-htmlbars/lib/keywords/action.js | @@ -4,7 +4,6 @@
*/
import Ember from "ember-metal/core"; // Handlebars, uuid, FEATURES, assert, deprecate
-import { get } from "ember-metal/property_get";
import { uuid } from "ember-metal/utils";
import run from "ember-metal/run_loop";
import { readUnwrappedModel } from "ember-views/streams/utils"; | true |
Other | emberjs | ember.js | 8732970e6bee9deea2fb17e68f658c1bb5387efd.json | Fix controller usage in {{action}} and sendAction | packages/ember-routing-htmlbars/lib/keywords/action.js | @@ -36,7 +36,7 @@ export default {
target = read(hash.target);
}
} else {
- target = get(env.view, 'controller') || read(scope.self);
+ target = read(scope.locals.controller) || read(scope.self);
}
return { actionName, actionArgs, target }; | true |
Other | emberjs | ember.js | 8732970e6bee9deea2fb17e68f658c1bb5387efd.json | Fix controller usage in {{action}} and sendAction | packages/ember-views/lib/views/component.js | @@ -118,6 +118,7 @@ var Component = View.extend(TargetActionSupport, ComponentTemplateDeprecation, {
init() {
this._super.apply(this, arguments);
+ set(this, 'controller', this);
set(this, 'context', this);
},
| true |
Other | emberjs | ember.js | 8732970e6bee9deea2fb17e68f658c1bb5387efd.json | Fix controller usage in {{action}} and sendAction | packages/ember-views/tests/views/component_test.js | @@ -29,7 +29,7 @@ QUnit.test("The context of an Ember.Component is itself", function() {
strictEqual(component, component.get('context'), "A component's context is itself");
});
-QUnit.skip("The controller (target of `action`) of an Ember.Component is itself", function() {
+QUnit.test("The controller (target of `action`) of an Ember.Component is itself", function() {
strictEqual(component, component.get('controller'), "A component's controller is itself");
});
@@ -108,7 +108,7 @@ QUnit.module("Ember.Component - Actions", {
});
component = Component.create({
- _parentView: EmberView.create({
+ parentView: EmberView.create({
controller: controller
})
});
@@ -127,7 +127,7 @@ QUnit.test("Calling sendAction on a component without an action defined does not
equal(sendCount, 0, "addItem action was not invoked");
});
-QUnit.skip("Calling sendAction on a component with an action defined calls send on the controller", function() {
+QUnit.test("Calling sendAction on a component with an action defined calls send on the controller", function() {
set(component, 'action', "addItem");
component.sendAction();
@@ -136,7 +136,7 @@ QUnit.skip("Calling sendAction on a component with an action defined calls send
equal(actionCounts['addItem'], 1, "addItem event was sent once");
});
-QUnit.skip("Calling sendAction with a named action uses the component's property as the action name", function() {
+QUnit.test("Calling sendAction with a named action uses the component's property as the action name", function() {
set(component, 'playing', "didStartPlaying");
set(component, 'action', "didDoSomeBusiness");
@@ -169,7 +169,7 @@ QUnit.test("Calling sendAction when the action name is not a string raises an ex
});
});
-QUnit.skip("Calling sendAction on a component with a context", function() {
+QUnit.test("Calling sendAction on a component with a context", function() {
set(component, 'playing', "didStartPlaying");
var testContext = { song: 'She Broke My Ember' };
@@ -179,7 +179,7 @@ QUnit.skip("Calling sendAction on a component with a context", function() {
deepEqual(actionArguments, [testContext], "context was sent with the action");
});
-QUnit.skip("Calling sendAction on a component with multiple parameters", function() {
+QUnit.test("Calling sendAction on a component with multiple parameters", function() {
set(component, 'playing', "didStartPlaying");
var firstContext = { song: 'She Broke My Ember' }; | true |
Other | emberjs | ember.js | c8dfd40c941fe917f19c2d462490ad1ecea63d18.json | Fix preventDefault on link-to | packages/ember-routing-views/lib/views/link.js | @@ -276,7 +276,7 @@ var LinkComponent = EmberComponent.extend({
_invoke(event) {
if (!isSimpleClick(event)) { return true; }
- if (this.preventDefault !== false) {
+ if (this.attrs.preventDefault !== false) {
var targetAttribute = this.attrs.target;
if (!targetAttribute || targetAttribute === '_self') {
event.preventDefault(); | true |
Other | emberjs | ember.js | c8dfd40c941fe917f19c2d462490ad1ecea63d18.json | Fix preventDefault on link-to | packages/ember/tests/helpers/link_to_test.js | @@ -1141,7 +1141,7 @@ QUnit.test("the {{link-to}} helper calls preventDefault", function() {
equal(event.isDefaultPrevented(), true, "should preventDefault");
});
-QUnit.skip("the {{link-to}} helper does not call preventDefault if `preventDefault=false` is passed as an option", function() {
+QUnit.test("the {{link-to}} helper does not call preventDefault if `preventDefault=false` is passed as an option", function() {
Ember.TEMPLATES.index = compile("{{#link-to 'about' id='about-link' preventDefault=false}}About{{/link-to}}");
Router.map(function() { | true |
Other | emberjs | ember.js | f68ceeb01a65f8c53e15ecfa3b2c3dad490493d0.json | Add support for intercepting get and set
These hooks are internal-only, not exposed publicly, and are only
intended to be used to emulate deprecated functionality for the moment. | packages/ember-htmlbars/tests/integration/mutable_binding_test.js | @@ -188,3 +188,40 @@ QUnit.test('a simple mutable binding using `mut` is available in hooks', functio
assert.strictEqual(bottom.attrs.setMe.value(), 13, "precond - the set took effect");
assert.strictEqual(view.get('val'), 13, "the set propagated back up");
});
+
+if (Ember.FEATURES.isEnabled('ember-htmlbars-component-generation')) {
+
+QUnit.test('mutable bindings work as angle-bracket component attributes', function(assert) {
+ var middle;
+
+ registry.register('component:middle-mut', Component.extend({
+ // no longer mutable
+ layout: compile('<bottom-mut setMe={{attrs.value}} />'),
+
+ didInsertElement() {
+ middle = this;
+ }
+ }));
+
+ registry.register('component:bottom-mut', Component.extend({
+ layout: compile('<p class="bottom">{{attrs.setMe}}</p>')
+ }));
+
+ view = EmberView.create({
+ container: container,
+ template: compile('<middle-mut value={{mut view.val}} />'),
+ val: 12
+ });
+
+ runAppend(view);
+
+ assert.strictEqual(view.$('p.bottom').text(), "12");
+
+ run(() => middle.attrs.value.update(13));
+
+ assert.strictEqual(middle.attrs.value.value(), 13, "precond - the set took effect");
+ assert.strictEqual(view.$('p.bottom').text(), "13");
+ assert.strictEqual(view.get('val'), 13, "the set propagated back up");
+});
+
+} | true |
Other | emberjs | ember.js | f68ceeb01a65f8c53e15ecfa3b2c3dad490493d0.json | Add support for intercepting get and set
These hooks are internal-only, not exposed publicly, and are only
intended to be used to emulate deprecated functionality for the moment. | packages/ember-metal/lib/property_get.js | @@ -10,9 +10,13 @@ import {
hasThis as pathHasThis
} from "ember-metal/path_cache";
import { hasPropertyAccessors } from "ember-metal/platform/define_property";
+import { symbol } from "ember-metal/utils";
var FIRST_KEY = /^([^\.]+)/;
+export let INTERCEPT_GET = symbol("INTERCEPT_GET");
+export let UNHANDLED_GET = symbol("UNHANDLED_GET");
+
// ..........................................................
// GET AND SET
//
@@ -62,6 +66,11 @@ export function get(obj, keyName) {
return _getPath(obj, keyName);
}
+ if (obj && typeof obj[INTERCEPT_GET] === 'function') {
+ let result = obj[INTERCEPT_GET](obj, keyName);
+ if (result !== UNHANDLED_GET) { return result; }
+ }
+
var meta = obj['__ember_meta__'];
var possibleDesc = obj[keyName];
var desc = (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) ? possibleDesc : undefined; | true |
Other | emberjs | ember.js | f68ceeb01a65f8c53e15ecfa3b2c3dad490493d0.json | Add support for intercepting get and set
These hooks are internal-only, not exposed publicly, and are only
intended to be used to emulate deprecated functionality for the moment. | packages/ember-metal/lib/property_set.js | @@ -12,6 +12,10 @@ import {
} from "ember-metal/path_cache";
import { hasPropertyAccessors } from "ember-metal/platform/define_property";
+import { symbol } from "ember-metal/utils";
+export let INTERCEPT_SET = symbol("INTERCEPT_SET");
+export let UNHANDLED_SET = symbol("UNHANDLED_SET");
+
/**
Sets the value of a property on an object, respecting computed properties
and notifying observers and other listeners of the change. If the
@@ -39,6 +43,14 @@ export function set(obj, keyName, value, tolerant) {
return setPath(obj, keyName, value, tolerant);
}
+ // This path exists purely to implement backwards-compatible
+ // effects (specifically, setting a property on a view may
+ // invoke a mutator on `attrs`).
+ if (obj && typeof obj[INTERCEPT_SET] === 'function') {
+ let result = obj[INTERCEPT_SET](obj, keyName, value, tolerant);
+ if (result !== UNHANDLED_SET) { return result; }
+ }
+
var meta, possibleDesc, desc;
if (obj) {
meta = obj['__ember_meta__']; | true |
Other | emberjs | ember.js | f68ceeb01a65f8c53e15ecfa3b2c3dad490493d0.json | Add support for intercepting get and set
These hooks are internal-only, not exposed publicly, and are only
intended to be used to emulate deprecated functionality for the moment. | packages/ember-metal/tests/accessors/get_test.js | @@ -1,7 +1,9 @@
import { testBoth } from 'ember-metal/tests/props_helper';
import {
get,
- getWithDefault
+ getWithDefault,
+ INTERCEPT_GET,
+ UNHANDLED_GET
} from 'ember-metal/property_get';
import {
Mixin,
@@ -30,6 +32,54 @@ QUnit.test('should get arbitrary properties on an object', function() {
});
+QUnit.test('should invoke INTERCEPT_GET even if the property exists', function() {
+ var obj = {
+ string: 'string',
+ number: 23,
+ boolTrue: true,
+ boolFalse: false,
+ nullValue: null
+ };
+
+ let calledWith;
+ obj[INTERCEPT_GET] = function(obj, key) {
+ calledWith = [obj, key];
+ return UNHANDLED_GET;
+ };
+
+ for (var key in obj) {
+ if (!obj.hasOwnProperty(key)) {
+ continue;
+ }
+ calledWith = undefined;
+ equal(get(obj, key), obj[key], key);
+ equal(calledWith[0], obj, 'the object was passed');
+ equal(calledWith[1], key, 'the key was passed');
+ }
+
+});
+
+QUnit.test('should invoke INTERCEPT_GET and accept a return value', function() {
+ var obj = {
+ string: 'string',
+ number: 23,
+ boolTrue: true,
+ boolFalse: false,
+ nullValue: null
+ };
+
+ obj[INTERCEPT_GET] = function(obj, key) {
+ return key;
+ };
+
+ for (var key in obj) {
+ if (!obj.hasOwnProperty(key) || key === INTERCEPT_GET) {
+ continue;
+ }
+ equal(get(obj, key), key, key);
+ }
+});
+
testBoth("should call unknownProperty on watched values if the value is undefined", function(get, set) {
var obj = {
count: 0, | true |
Other | emberjs | ember.js | f68ceeb01a65f8c53e15ecfa3b2c3dad490493d0.json | Add support for intercepting get and set
These hooks are internal-only, not exposed publicly, and are only
intended to be used to emulate deprecated functionality for the moment. | packages/ember-metal/tests/accessors/set_test.js | @@ -1,5 +1,5 @@
-import { get } from 'ember-metal/property_get';
-import { set } from 'ember-metal/property_set';
+import { get, INTERCEPT_GET } from 'ember-metal/property_get';
+import { set, INTERCEPT_SET, UNHANDLED_SET } from 'ember-metal/property_set';
QUnit.module('set');
@@ -27,6 +27,115 @@ QUnit.test('should set arbitrary properties on an object', function() {
}
});
+QUnit.test('should call INTERCEPT_SET and support UNHANDLED_SET if INTERCEPT_SET is defined', function() {
+ var obj = {
+ string: 'string',
+ number: 23,
+ boolTrue: true,
+ boolFalse: false,
+ nullValue: null,
+ undefinedValue: undefined
+ };
+
+ var newObj = {
+ undefinedValue: 'emberjs'
+ };
+
+ let calledWith;
+ newObj[INTERCEPT_SET] = function(obj, key, value) {
+ calledWith = [key, value];
+ return UNHANDLED_SET;
+ };
+
+ for (var key in obj) {
+ if (!obj.hasOwnProperty(key)) {
+ continue;
+ }
+
+ calledWith = undefined;
+
+ equal(set(newObj, key, obj[key]), obj[key], 'should return value');
+ equal(calledWith[0], key, 'INTERCEPT_SET called with the key');
+ equal(calledWith[1], obj[key], 'INTERCEPT_SET called with the key');
+ equal(get(newObj, key), obj[key], 'should set value since UNHANDLED_SET was returned');
+ }
+});
+
+QUnit.test('should call INTERCEPT_SET and support handling the set if it is defined', function() {
+ var obj = {
+ string: 'string',
+ number: 23,
+ boolTrue: true,
+ boolFalse: false,
+ nullValue: null,
+ undefinedValue: undefined
+ };
+
+ var newObj = {
+ bucket: {}
+ };
+
+ let calledWith;
+ newObj[INTERCEPT_SET] = function(obj, key, value) {
+ set(obj.bucket, key, value);
+ return value;
+ };
+
+ for (var key in obj) {
+ if (!obj.hasOwnProperty(key)) {
+ continue;
+ }
+
+ calledWith = undefined;
+
+ equal(set(newObj, key, obj[key]), obj[key], 'should return value');
+ equal(get(newObj.bucket, key), obj[key], 'should have moved the value to `bucket`');
+ ok(newObj.bucket.hasOwnProperty(key), 'the key is defined in bucket');
+ ok(!newObj.hasOwnProperty(key), 'the key is not defined on the raw object');
+ }
+});
+
+QUnit.test('should call INTERCEPT_GET and INTERCEPT_SET', function() {
+ var obj = {
+ string: 'string',
+ number: 23,
+ boolTrue: true,
+ boolFalse: false,
+ nullValue: null,
+ undefinedValue: undefined
+ };
+
+ var newObj = {
+ string: null,
+ number: null,
+ boolTrue: null,
+ boolFalse: null,
+ nullValue: null,
+ undefinedValue: null,
+ bucket: {}
+ };
+
+ newObj[INTERCEPT_SET] = function(obj, key, value) {
+ set(obj.bucket, key, value);
+ return value;
+ };
+
+ newObj[INTERCEPT_GET] = function(obj, key) {
+ return get(obj.bucket, key);
+ };
+
+ for (var key in obj) {
+ if (!obj.hasOwnProperty(key)) {
+ continue;
+ }
+
+ equal(set(newObj, key, obj[key]), obj[key], 'should return value');
+ equal(get(newObj.bucket, key), obj[key], 'should have moved the value to `bucket`');
+ equal(get(newObj, key), obj[key], 'INTERCEPT_GET was called');
+ }
+});
+
+
QUnit.test('should call setUnknownProperty if defined and value is undefined', function() {
var obj = { | true |
Other | emberjs | ember.js | d31876afb241986978d7c4472fc12ddfc195f9c7.json | Resolve master merge conflicts | .travis.yml | @@ -52,5 +52,5 @@ env:
- TEST_SUITE=built-tests EMBER_ENV=production DISABLE_JSCS=true DISABLE_JSHINT=true
- TEST_SUITE=old-jquery
- TEST_SUITE=extend-prototypes
- - TEST_SUITE=node EMBER_ENV=production DISABLE_JSCS=true DISABLE_JSHINT=true
+ - TEST_SUITE=node DISABLE_JSCS=true DISABLE_JSHINT=true
- TEST_SUITE=sauce | true |
Other | emberjs | ember.js | d31876afb241986978d7c4472fc12ddfc195f9c7.json | Resolve master merge conflicts | packages/container/lib/container.js | @@ -7,7 +7,7 @@ import dictionary from 'ember-metal/dictionary';
var Registry;
/**
- A lightweight container used to instantiate and cache objects.
+ A container used to instantiate and cache objects.
Every `Container` must be associated with a `Registry`, which is referenced
to determine the factory and options that should be used to instantiate | true |
Other | emberjs | ember.js | d31876afb241986978d7c4472fc12ddfc195f9c7.json | Resolve master merge conflicts | packages/container/lib/registry.js | @@ -10,7 +10,7 @@ if (Ember.FEATURES.isEnabled('ember-application-instance-initializers')) {
}
/**
- A lightweight registry used to store factory and option information keyed
+ A registry used to store factory and option information keyed
by type.
A `Registry` stores the factory and option information needed by a | true |
Other | emberjs | ember.js | d31876afb241986978d7c4472fc12ddfc195f9c7.json | Resolve master merge conflicts | packages/ember-application/lib/system/application.js | @@ -376,6 +376,7 @@ var Application = Namespace.extend(DeferredMixin, {
var App = Ember.Application.create();
App.deferReadiness();
+
// Ember.$ is a reference to the jQuery object/function
Ember.$.getJSON('/auth-token', function(token) {
App.token = token;
@@ -456,9 +457,9 @@ var Application = Namespace.extend(DeferredMixin, {
```javascript
var App = Ember.Application.create();
- App.Person = Ember.Object.extend();
- App.Orange = Ember.Object.extend();
- App.Email = Ember.Object.extend();
+ App.Person = Ember.Object.extend();
+ App.Orange = Ember.Object.extend();
+ App.Email = Ember.Object.extend();
App.session = Ember.Object.create();
App.register('model:user', App.Person, { singleton: false });
@@ -758,6 +759,7 @@ var Application = Namespace.extend(DeferredMixin, {
// This method must be moved to the application instance object
willDestroy() {
+ this._super(...arguments);
Ember.BOOTED = false;
this._bootPromise = null;
this._bootResolver = null; | true |
Other | emberjs | ember.js | d31876afb241986978d7c4472fc12ddfc195f9c7.json | Resolve master merge conflicts | packages/ember-htmlbars/lib/keywords/component.js | @@ -1,9 +1,11 @@
export default {
setupState(lastState, env, scope, params, hash) {
- return {
+ let state = {
componentPath: env.hooks.getValue(params[0]),
componentNode: lastState && lastState.componentNode
};
+
+ return state;
},
render(morph, env, scope, params, hash, template, inverse, visitor) {
@@ -12,6 +14,14 @@ export default {
// but the `{{component}}` helper can.
morph.state.componentNode = null;
- env.hooks.component(morph, env, scope, morph.state.componentPath, hash, template, visitor);
+ let componentPath = morph.state.componentPath;
+
+ // If the value passed to the {{component}} helper is undefined or null,
+ // don't create a new ComponentNode.
+ if (componentPath === undefined || componentPath === null) {
+ return;
+ }
+
+ env.hooks.component(morph, env, scope, componentPath, hash, template, visitor);
}
}; | true |
Other | emberjs | ember.js | d31876afb241986978d7c4472fc12ddfc195f9c7.json | Resolve master merge conflicts | packages/ember-htmlbars/lib/templates/select-option.hbs | @@ -1 +1 @@
-{{view.label}}
\ No newline at end of file
+{{~view.label~}} | true |
Other | emberjs | ember.js | d31876afb241986978d7c4472fc12ddfc195f9c7.json | Resolve master merge conflicts | packages/ember-htmlbars/tests/helpers/component_test.js | @@ -153,6 +153,26 @@ if (Ember.FEATURES.isEnabled('ember-htmlbars-component-helper')) {
}, /HTMLBars error: Could not find component named "does-not-exist"./, "Expected missing component to generate an exception");
});
+ QUnit.test("component with unquoted param resolving to a component, then non-existent component", function() {
+ registry.register('template:components/foo-bar', compile('yippie! {{attrs.location}} {{yield}}'));
+ view = EmberView.create({
+ container: container,
+ dynamicComponent: 'foo-bar',
+ location: 'Caracas',
+ template: compile('{{#component view.dynamicComponent location=view.location}}arepas!{{/component}}')
+ });
+
+ runAppend(view);
+
+ equal(view.$().text(), 'yippie! Caracas arepas!', 'component was looked up and rendered');
+
+ Ember.run(function() {
+ set(view, "dynamicComponent", undefined);
+ });
+
+ equal(view.$().text(), '', 'component correctly deals with falsey values set post-render');
+ });
+
QUnit.test("component with quoted param for non-existent component", function() {
view = EmberView.create({
container: container, | true |
Other | emberjs | ember.js | d31876afb241986978d7c4472fc12ddfc195f9c7.json | Resolve master merge conflicts | packages/ember-metal/lib/core.js | @@ -94,11 +94,14 @@ if ('undefined' === typeof Ember.ENV.DISABLE_RANGE_API) {
@static
@since 1.1.0
*/
+Ember.FEATURES = DEFAULT_FEATURES; //jshint ignore:line
-Ember.FEATURES = Ember.ENV.FEATURES;
-
-if (!Ember.FEATURES) {
- Ember.FEATURES = DEFAULT_FEATURES; //jshint ignore:line
+if (Ember.ENV.FEATURES) {
+ for (var feature in Ember.ENV.FEATURES) {
+ if (Ember.ENV.FEATURES.hasOwnProperty(feature)) {
+ Ember.FEATURES[feature] = Ember.ENV.FEATURES[feature];
+ }
+ }
}
/** | true |
Other | emberjs | ember.js | d31876afb241986978d7c4472fc12ddfc195f9c7.json | Resolve master merge conflicts | packages/ember-metal/lib/expand_properties.js | @@ -22,7 +22,7 @@ var SPLIT_REGEX = /\{|\}/;
Ember.expandProperties('foo.bar', echo); //=> 'foo.bar'
Ember.expandProperties('{foo,bar}', echo); //=> 'foo', 'bar'
Ember.expandProperties('foo.{bar,baz}', echo); //=> 'foo.bar', 'foo.baz'
- Ember.expandProperties('{foo,bar}.baz', echo); //=> '{foo,bar}.baz'
+ Ember.expandProperties('{foo,bar}.baz', echo); //=> 'foo.baz', 'bar.baz'
Ember.expandProperties('foo.{bar,baz}.@each', echo) //=> 'foo.bar.@each', 'foo.baz.@each'
Ember.expandProperties('{foo,bar}.{spam,eggs}', echo) //=> 'foo.spam', 'foo.eggs', 'bar.spam', 'bar.eggs'
Ember.expandProperties('{foo}.bar.{baz}') //=> 'foo.bar.baz' | true |
Other | emberjs | ember.js | d31876afb241986978d7c4472fc12ddfc195f9c7.json | Resolve master merge conflicts | packages/ember-metal/lib/run_loop.js | @@ -126,12 +126,12 @@ run.join = function() {
```javascript
App.RichTextEditorComponent = Ember.Component.extend({
- initializeTinyMCE: function() {
+ initializeTinyMCE: Ember.on('didInsertElement', function() {
tinymce.init({
selector: '#' + this.$().prop('id'),
setup: Ember.run.bind(this, this.setupEditor)
});
- }.on('didInsertElement'),
+ }),
setupEditor: function(editor) {
this.set('editor', editor); | true |
Other | emberjs | ember.js | d31876afb241986978d7c4472fc12ddfc195f9c7.json | Resolve master merge conflicts | packages/ember-runtime/lib/mixins/promise_proxy.js | @@ -34,7 +34,7 @@ function tap(proxy, promise) {
}
/**
- A low level mixin making ObjectProxy, ObjectController or ArrayController's promise aware.
+ A low level mixin making ObjectProxy, ObjectController or ArrayControllers promise-aware.
```javascript
var ObjectPromiseController = Ember.ObjectController.extend(Ember.PromiseProxyMixin); | true |
Other | emberjs | ember.js | d31876afb241986978d7c4472fc12ddfc195f9c7.json | Resolve master merge conflicts | packages/ember-views/lib/views/component.js | @@ -140,19 +140,18 @@ var Component = View.extend(TargetActionSupport, ComponentTemplateDeprecation, {
@deprecated
@property template
*/
- template: computed({
- get: function() {
+ template: computed('templateName', {
+ get() {
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) {
+ set(key, value) {
return value;
}
- }).property('templateName'),
+ }),
/**
Specifying a components `templateName` is deprecated without also | true |
Other | emberjs | ember.js | d31876afb241986978d7c4472fc12ddfc195f9c7.json | Resolve master merge conflicts | packages/ember-views/lib/views/select.js | @@ -22,8 +22,8 @@ import { observer } from "ember-metal/mixin";
import { defineProperty } from "ember-metal/properties";
import htmlbarsTemplate from "ember-htmlbars/templates/select";
-import selectOptionTemplate from "ember-htmlbars/templates/select-option";
-import selectOptgroupTemplate from "ember-htmlbars/templates/select-optgroup";
+import selectOptionDefaultTemplate from "ember-htmlbars/templates/select-option";
+import selectOptgroupDefaultTemplate from "ember-htmlbars/templates/select-optgroup";
var defaultTemplate = htmlbarsTemplate;
@@ -33,7 +33,7 @@ var SelectOption = View.extend({
tagName: 'option',
attributeBindings: ['value', 'selected'],
- defaultTemplate: selectOptionTemplate,
+ defaultTemplate: selectOptionDefaultTemplate,
content: null,
@@ -69,7 +69,7 @@ var SelectOptgroup = View.extend({
instrumentDisplay: 'Ember.SelectOptgroup',
tagName: 'optgroup',
- defaultTemplate: selectOptgroupTemplate,
+ defaultTemplate: selectOptgroupDefaultTemplate,
attributeBindings: ['label']
});
@@ -92,7 +92,7 @@ var SelectOptgroup = View.extend({
Example:
```javascript
- App.ApplicationController = Ember.ObjectController.extend({
+ App.ApplicationController = Ember.Controller.extend({
names: ["Yehuda", "Tom"]
});
```
@@ -114,7 +114,7 @@ var SelectOptgroup = View.extend({
`value` property:
```javascript
- App.ApplicationController = Ember.ObjectController.extend({
+ App.ApplicationController = Ember.Controller.extend({
selectedName: 'Tom',
names: ["Yehuda", "Tom"]
});
@@ -151,7 +151,7 @@ var SelectOptgroup = View.extend({
element's text. Both paths must reference each object itself as `content`:
```javascript
- App.ApplicationController = Ember.ObjectController.extend({
+ App.ApplicationController = Ember.Controller.extend({
programmers: [
{firstName: "Yehuda", id: 1},
{firstName: "Tom", id: 2}
@@ -179,7 +179,7 @@ var SelectOptgroup = View.extend({
can be bound to a property on another object:
```javascript
- App.ApplicationController = Ember.ObjectController.extend({
+ App.ApplicationController = Ember.Controller.extend({
programmers: [
{firstName: "Yehuda", id: 1},
{firstName: "Tom", id: 2}
@@ -222,7 +222,7 @@ var SelectOptgroup = View.extend({
var yehuda = {firstName: "Yehuda", id: 1, bff4eva: 'tom'}
var tom = {firstName: "Tom", id: 2, bff4eva: 'yehuda'};
- App.ApplicationController = Ember.ObjectController.extend({
+ App.ApplicationController = Ember.Controller.extend({
selectedPerson: tom,
programmers: [ yehuda, tom ]
});
@@ -256,7 +256,7 @@ var SelectOptgroup = View.extend({
results in there being no `<option>` with a `selected` attribute:
```javascript
- App.ApplicationController = Ember.ObjectController.extend({
+ App.ApplicationController = Ember.Controller.extend({
selectedProgrammer: null,
programmers: ["Yehuda", "Tom"]
});
@@ -285,7 +285,7 @@ var SelectOptgroup = View.extend({
with the `prompt` option:
```javascript
- App.ApplicationController = Ember.ObjectController.extend({
+ App.ApplicationController = Ember.Controller.extend({
selectedProgrammer: null,
programmers: [ "Yehuda", "Tom" ]
}); | true |
Other | emberjs | ember.js | d31876afb241986978d7c4472fc12ddfc195f9c7.json | Resolve master merge conflicts | packages/ember-views/lib/views/states/default.js | @@ -1,7 +1,5 @@
import EmberError from "ember-metal/error";
-function K() { return this; }
-
/**
@module ember
@submodule ember-views
@@ -25,9 +23,9 @@ export default {
return true; // continue event propagation
},
- cleanup: K,
- destroyElement: K,
+ cleanup() { } ,
+ destroyElement() { },
- rerender: K,
- invokeObserver: K
+ rerender() { },
+ invokeObserver() { }
}; | true |
Other | emberjs | ember.js | d31876afb241986978d7c4472fc12ddfc195f9c7.json | Resolve master merge conflicts | packages/ember-views/lib/views/states/pre_render.js | @@ -5,6 +5,4 @@ import create from 'ember-metal/platform/create';
@module ember
@submodule ember-views
*/
-var preRender = create(_default);
-
-export default preRender;
+export default create(_default); | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.