Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX beta] Only pass isComponent with a dash #11222

Merged
merged 1 commit into from
May 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.