Skip to content

Commit

Permalink
Merge pull request #11222 from mixonic/component-stuff
Browse files Browse the repository at this point in the history
[BUGFIX beta] Only pass isComponent with a dash
  • Loading branch information
rwjblue committed May 19, 2015
2 parents c56f6b3 + 3364788 commit e09b0ef
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 41 deletions.
4 changes: 3 additions & 1 deletion packages/ember-htmlbars/lib/utils/is-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
@submodule ember-htmlbars
*/

import { ISNT_HELPER_CACHE } from "ember-htmlbars/system/lookup-helper";

/*
Given a path name, returns whether or not a component with that
name was found in the container.
*/
export default function isComponent(env, scope, path) {
var container = env.container;
if (!container) { return false; }

if (ISNT_HELPER_CACHE.get(path)) { return false; }
return container._registry.has('component:' + path) ||
container._registry.has('template:components/' + path);
}
15 changes: 15 additions & 0 deletions packages/ember-htmlbars/tests/helpers/component_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,19 @@ if (Ember.FEATURES.isEnabled('ember-htmlbars-component-helper')) {
});
equal(view.$().text(), 'Max - Max|James - James|', 'component was updated and re-rendered');
});

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('{{component "dashless"}}'),
container: container
}).create();

expectAssertion(function() {
runAppend(view);
}, /You cannot use 'dashless' as a component name. Component names must contain a hyphen./);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ QUnit.test("should be able to update when bound property updates", function() {
equal(view.$('i').text(), 'second, second - computed', "view rerenders when bound properties change");
});

QUnit.test('should allow rendering of undefined props', function() {
view = EmberView.create({
template: compile('{{name}}')
});

runAppend(view);

equal(view.$().text(), '', 'rendered undefined binding');
});

QUnit.test('should cleanup bound properties on rerender', function() {
view = EmberView.create({
controller: EmberObject.create({ name: 'wycats' }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,43 @@ QUnit.test('non-block with properties on attrs and component class', function()
equal(jQuery('#qunit-fixture').text(), 'In layout - someProp: something here');
});

QUnit.test('lookup of component takes priority over property', function() {
expect(1);

registry.register('template:components/some-component', compile('some-component'));

view = EmberView.extend({
template: compile('{{some-prop}} {{some-component}}'),
container: container,
context: {
'some-component': 'not-some-component',
'some-prop': 'some-prop'
}
}).create();

runAppend(view);

equal(jQuery('#qunit-fixture').text(), 'some-prop some-component');
});

QUnit.test('component without dash is not looked up', function() {
expect(1);

registry.register('template:components/somecomponent', compile('somecomponent'));

view = EmberView.extend({
template: compile('{{somecomponent}}'),
container: container,
context: {
'somecomponent': 'notsomecomponent'
}
}).create();

runAppend(view);

equal(jQuery('#qunit-fixture').text(), 'notsomecomponent');
});

QUnit.test('rerendering component with attrs from parent', function() {
var willUpdate = 0;
var didReceiveAttrs = 0;
Expand Down
40 changes: 0 additions & 40 deletions packages/ember-htmlbars/tests/integration/component_lookup_test.js

This file was deleted.

0 comments on commit e09b0ef

Please sign in to comment.