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

[FEATURE ember-glimmer-angle-bracket-built-ins] enable 👌 #17811

Merged
merged 2 commits into from
Mar 29, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -114,37 +114,68 @@ if (EMBER_GLIMMER_ANGLE_BRACKET_BUILT_INS) {
dragend: 'dragEnd',
};

let TestComponent = Component.extend({ tagName: 'input' });
this.registerComponent('test-component', { ComponentClass: TestComponent });

let triggeredEvents = [];
let actions = {};
Object.keys(events).forEach(evt => {
actions[`run_${evt}`] = function() {
triggeredEvents.push(evt);
};
this.registerComponent('test-component', {
ComponentClass: Component.extend({
tagName: 'input',
attributeBindings: ['type'],
}),
});

let typeAttr = type ? `type="${type}" ` : '';
let actionAttrs = Object.keys(events)
.map(evt => `@${events[evt]}={{action 'run_${evt}'}}`)
.join(' ');
let template = `<TestComponent ${typeAttr}${actionAttrs} /><Input ${typeAttr}${actionAttrs} />`;
let triggered = {
standard: [],
custom: [],
};

let actions = {
didTrigger(id, event) {
triggered[id].push(event);
},
};

function argsFor(id) {
let args = [`id="${id}"`];

if (type) {
args.push(`@type="${type}"`);
}

Object.keys(events).forEach(event => {
args.push(`@${events[event]}={{action "didTrigger" "${id}" "${event}"}}`);
});

return args.join(' ');
}

let template = `
<Input ${argsFor('standard')} />
<TestComponent ${argsFor('custom')} />
`;

this.render(template, { actions });

Object.keys(events).forEach(evt => this.triggerEvent(evt, null, 'input:first-of-type'));
let normallyTriggeredEvents = [].concat(triggeredEvents);
triggeredEvents.length = 0;
this.assert.ok(this.$('input').length === 2);

let $standard = this.$('#standard');
let $custom = this.$('#custom');

this.assert.equal($standard.type, $custom.type);

Object.keys(events).forEach(event => {
this.triggerEvent(event, null, '#standard');
this.triggerEvent(event, null, '#custom');
});

this.assert.ok(
normallyTriggeredEvents.length > 10,
'sanity check that most events are triggered'
triggered.standard.length > 10,
'sanity check that most events are triggered (standard)'
);

normallyTriggeredEvents.forEach(evt => this.triggerEvent(evt, null, 'input:last-of-type'));
this.assert.ok(
triggered.custom.length > 10,
'sanity check that most events are triggered (custom)'
);

this.assert.deepEqual(triggeredEvents, normallyTriggeredEvents, 'called for all events');
this.assert.deepEqual(triggered.standard, triggered.custom, 'called for all events');
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/@ember/canary-features/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const DEFAULT_FEATURES = {
EMBER_IMPROVED_INSTRUMENTATION: null,
EMBER_MODULE_UNIFICATION: null,
EMBER_METAL_TRACKED_PROPERTIES: null,
EMBER_GLIMMER_ANGLE_BRACKET_BUILT_INS: null,
EMBER_GLIMMER_ANGLE_BRACKET_BUILT_INS: true,
EMBER_GLIMMER_ANGLE_BRACKET_NESTED_LOOKUP: true,
EMBER_ROUTING_BUILD_ROUTEINFO_METADATA: true,
EMBER_NATIVE_DECORATOR_SUPPORT: null,
Expand Down