Skip to content

Commit

Permalink
fix: deprecate partial application
Browse files Browse the repository at this point in the history
  • Loading branch information
buschtoens committed Apr 15, 2019
1 parent 53de1b3 commit 5b337d4
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions addon/modifiers/on.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import Ember from 'ember';
import { addEventListener, removeEventListener } from '../utils/event-listener';
import { assert } from '@ember/debug';
import { deprecate } from '@ember/application/deprecations';
import { DEBUG } from '@glimmer/env';

const assertValidEventOptions =
Expand All @@ -29,6 +30,16 @@ const assertValidEventOptions =

function setupListener(element, eventName, callback, eventOptions, params) {
if (DEBUG) assertValidEventOptions(eventOptions, eventName);
deprecate(
`ember-on-modifier: Passing additional arguments to be partially applied to the event listener is deprecated in order to comply with the RFC. Use the '{{fn}}' helper instead: https://www.npmjs.com/package/ember-fn-helper`,
!Array.isArray(params) || params.length === 0,
{
id: 'ember-on-modifier.partial-application',
until: '1.0.0',
url:
'https://github.com/emberjs/rfcs/blob/master/text/0471-on-modifier.md'
}
);

if (typeof eventName === 'string' && typeof callback === 'function') {
if (Array.isArray(params) && params.length > 0) {
Expand Down

0 comments on commit 5b337d4

Please sign in to comment.