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 lts] Pass the event parameter to sendAction #17115

Merged
merged 1 commit into from Oct 13, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -3,6 +3,7 @@ import { set } from '@ember/-internals/metal';
import { Component } from '../../utils/helpers';
import { RenderingTest, moduleFor } from '../../utils/test-case';
import { runDestroy } from 'internal-test-helpers';
import { jQuery } from '@ember/-internals/views';

class InputRenderingTest extends RenderingTest {
$input() {
Expand Down Expand Up @@ -274,13 +275,14 @@ moduleFor(
['@test [DEPRECATED] sends an action with `{{input enter="foo"}}` when <enter> is pressed'](
assert
) {
assert.expect(3);
assert.expect(4);

expectDeprecation(() => {
this.render(`{{input enter='foo'}}`, {
actions: {
foo() {
foo(value, event) {
assert.ok(true, 'action was triggered');
assert.ok(event instanceof jQuery.Event, 'jQuery event was passed.');
},
},
});
Expand All @@ -293,11 +295,12 @@ moduleFor(
['@test sends an action with `{{input enter=(action "foo")}}` when <enter> is pressed'](
assert
) {
assert.expect(1);
assert.expect(2);
this.render(`{{input enter=(action 'foo')}}`, {
actions: {
foo() {
foo(value, event) {
assert.ok(true, 'action was triggered');
assert.ok(event instanceof jQuery.Event, 'jQuery event was passed');
},
},
});
Expand All @@ -308,15 +311,16 @@ moduleFor(
}

['@test [DEPRECATED] sends an action with `{{input key-press="foo"}}` is pressed'](assert) {
assert.expect(3);
assert.expect(4);

expectDeprecation(() => {
this.render(`{{input value=value key-press='foo'}}`, {
value: 'initial',

actions: {
foo() {
foo(value, event) {
assert.ok(true, 'action was triggered');
assert.ok(event instanceof jQuery.Event, 'jQuery event was passed');
},
},
});
Expand All @@ -328,14 +332,15 @@ moduleFor(
}

['@test sends an action with `{{input key-press=(action "foo")}}` is pressed'](assert) {
assert.expect(1);
assert.expect(2);

this.render(`{{input value=value key-press=(action 'foo')}}`, {
value: 'initial',

actions: {
foo() {
foo(value, event) {
assert.ok(true, 'action was triggered');
assert.ok(event instanceof jQuery.Event, 'jQuery event was passed');
},
},
});
Expand Down Expand Up @@ -380,12 +385,13 @@ moduleFor(
}

['@test sends `insert-newline` when <enter> is pressed'](assert) {
assert.expect(1);
assert.expect(2);

this.render(`{{input insert-newline=(action 'foo')}}`, {
actions: {
foo() {
foo(value, event) {
assert.ok(true, 'action was triggered');
assert.ok(event instanceof jQuery.Event, 'jQuery event was passed');
},
},
});
Expand All @@ -398,13 +404,14 @@ moduleFor(
['@test [DEPRECATED] sends an action with `{{input escape-press="foo"}}` when <escape> is pressed'](
assert
) {
assert.expect(3);
assert.expect(4);

expectDeprecation(() => {
this.render(`{{input escape-press='foo'}}`, {
actions: {
foo() {
foo(value, event) {
assert.ok(true, 'action was triggered');
assert.ok(event instanceof jQuery.Event, 'jQuery event was passed');
},
},
});
Expand All @@ -418,12 +425,13 @@ moduleFor(
['@test sends an action with `{{input escape-press=(action "foo")}}` when <escape> is pressed'](
assert
) {
assert.expect(1);
assert.expect(2);

this.render(`{{input escape-press=(action 'foo')}}`, {
actions: {
foo() {
foo(value, event) {
assert.ok(true, 'action was triggered');
assert.ok(event instanceof jQuery.Event, 'jQuery event was passed');
},
},
});
Expand All @@ -434,13 +442,14 @@ moduleFor(
['@test [DEPRECATED] sends an action with `{{input key-down="foo"}}` when a key is pressed'](
assert
) {
assert.expect(3);
assert.expect(4);

expectDeprecation(() => {
this.render(`{{input key-down='foo'}}`, {
actions: {
foo() {
foo(value, event) {
assert.ok(true, 'action was triggered');
assert.ok(event instanceof jQuery.Event, 'jQuery event was passed');
},
},
});
Expand All @@ -454,12 +463,13 @@ moduleFor(
['@test sends an action with `{{input key-down=(action "foo")}}` when a key is pressed'](
assert
) {
assert.expect(1);
assert.expect(2);

this.render(`{{input key-down=(action 'foo')}}`, {
actions: {
foo() {
foo(value, event) {
assert.ok(true, 'action was triggered');
assert.ok(event instanceof jQuery.Event, 'jQuery event was passed');
},
},
});
Expand All @@ -470,13 +480,14 @@ moduleFor(
['@test [DEPRECATED] sends an action with `{{input key-up="foo"}}` when a key is pressed'](
assert
) {
assert.expect(3);
assert.expect(4);

expectDeprecation(() => {
this.render(`{{input key-up='foo'}}`, {
actions: {
foo() {
foo(value, event) {
assert.ok(true, 'action was triggered');
assert.ok(event instanceof jQuery.Event, 'jQuery event was passed');
},
},
});
Expand All @@ -490,12 +501,13 @@ moduleFor(
['@test [DEPRECATED] sends an action with `{{input key-up=(action "foo")}}` when a key is pressed'](
assert
) {
assert.expect(1);
assert.expect(2);

this.render(`{{input key-up=(action 'foo')}}`, {
actions: {
foo() {
foo(value, event) {
assert.ok(true, 'action was triggered');
assert.ok(event instanceof jQuery.Event, 'jQuery event was passed');
},
},
});
Expand Down
4 changes: 2 additions & 2 deletions packages/@ember/-internals/views/lib/mixins/text_support.js
Expand Up @@ -321,10 +321,10 @@ function sendAction(eventName, view, event) {
);
view.triggerAction({
action: actionName,
actionContext: [value],
actionContext: [value, event],
});
} else if (typeof actionName === 'function') {
actionName(value);
actionName(value, event);
}

if (actionName && !get(view, 'bubbles')) {
Expand Down