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

Update manager capabilities to 3.22 to fix deprecation in Ember 3.26 #33

Closed
Closed
10 changes: 5 additions & 5 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ jobs:
with:
node-version: 10.x
- name: install dependencies
run: yarn install
run: npm install
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should need to switch from yarn to npm here, right?

- name: lint:js
run: yarn lint:js
run: npm run lint:js
- name: lint:hbs
run: yarn lint:hbs
run: npm run lint:hbs
- name: test
run: yarn test
run: npm run test

try-scenarios:
name: ${{ matrix.ember-try-scenario }}
Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:
with:
node-version: 12.x
- name: install dependencies
run: yarn install
run: npm install
- name: test
env:
EMBER_TRY_SCENARIO: ${{ matrix.ember-try-scenario }}
Expand Down
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

* `git clone <repository-url>`
* `cd @ember/render-modifiers`
* `yarn install`
* `npm install`

## Linting

* `yarn lint:hbs`
* `yarn lint:js`
* `yarn lint:js --fix`
* `npm run lint:hbs`
* `npm run lint:js`
* `npm run lint:js --fix`

## Running tests

Expand All @@ -23,4 +23,4 @@
* `ember serve`
* Visit the dummy application at [http://localhost:4200](http://localhost:4200).

For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).
For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).
10 changes: 5 additions & 5 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ Once the prep work is completed, the actual release is straight forward:
# using https://volta.sh
volta install release-it

# using Yarn
yarn global add release-it
# using npm
npm i -g release-it

# using npm
npm install --global release-it
npm i -g release-it
```

* Second, ensure that you have installed your projects dependencies:

```
# using yarn
yarn install
# using npm
npm install

# using npm
npm install
Expand Down
12 changes: 3 additions & 9 deletions addon/modifiers/did-insert.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { setModifierManager, capabilities } from '@ember/modifier';
import { gte } from 'ember-compatibility-helpers';

/**
The `{{did-insert}}` element modifier is activated when an element is
Expand Down Expand Up @@ -46,18 +47,11 @@ import { setModifierManager, capabilities } from '@ember/modifier';
*/
export default setModifierManager(
() => ({
capabilities: capabilities('3.13', { disableAutoTracking: true }),
capabilities: capabilities(gte('3.22.0') ? '3.22' : '3.13', { disableAutoTracking: true }),

createModifier() {},

installModifier(
_state,
element,
{
positional: [fn, ...args],
named,
}
) {
installModifier(_state, element, { positional: [fn, ...args], named }) {
fn(element, args, named);
},

Expand Down
26 changes: 23 additions & 3 deletions addon/modifiers/did-update.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { setModifierManager, capabilities } from '@ember/modifier';
import { gte } from 'ember-compatibility-helpers';

/**
The `{{did-update}}` element modifier is activated when any of its arguments
Expand Down Expand Up @@ -58,19 +59,38 @@ import { setModifierManager, capabilities } from '@ember/modifier';
*/
export default setModifierManager(
() => ({
capabilities: capabilities('3.13', { disableAutoTracking: true }),
capabilities: gte('3.22.0')
? capabilities('3.22', { disableAutoTracking: false })
: capabilities('3.13', { disableAutoTracking: true }),

createModifier() {
return { element: null };
},
installModifier(state, element) {
installModifier(state, element, args) {
// save element into state bucket
state.element = element;
if (gte('3.22.0')) {
// consume all args
rwjblue marked this conversation as resolved.
Show resolved Hide resolved
for (let i = 0; i < args.positional.length; i++) {
args.positional[i]; // "noop" / consume the arg
}
for (let key of Object.keys(args.named)) {
args.named[key]; // "noop" / consume the arg
}
}
},

updateModifier({ element }, args) {
if (gte('3.22.0')) {
// consume all args
for (let i = 0; i < args.positional.length; i++) {
args.positional[i]; // "noop" / consume the arg
}
for (let key of Object.keys(args.named)) {
args.named[key]; // "noop" / consume the arg
}
}
let [fn, ...positional] = args.positional;

fn(element, positional, args.named);
},

Expand Down
3 changes: 2 additions & 1 deletion addon/modifiers/will-destroy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { setModifierManager, capabilities } from '@ember/modifier';
import { gte } from 'ember-compatibility-helpers';

/**
The `{{will-destroy}}` element modifier is activated immediately before the element
Expand Down Expand Up @@ -40,7 +41,7 @@ import { setModifierManager, capabilities } from '@ember/modifier';
*/
export default setModifierManager(
() => ({
capabilities: capabilities('3.13', { disableAutoTracking: true }),
capabilities: capabilities(gte('3.22.0') ? '3.22' : '3.13', { disableAutoTracking: true }),

createModifier() {
return { element: null };
Expand Down
3 changes: 1 addition & 2 deletions config/ember-try.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ module.exports = function() {
getChannelURL('canary'),
]).then(urls => {
return {
useYarn: true,
scenarios: [
{
name: 'ember-lts-2.18',
Expand Down Expand Up @@ -95,7 +94,7 @@ module.exports = function() {
},
},
},
// The default `.travis.yml` runs this scenario via `yarn test`,
// The default `.travis.yml` runs this scenario via `npm run test`,
// not via `ember try`. It's still included here so that running
// `ember try:each` manually or from a customized CI config will run it
// along with all the other scenarios.
Expand Down
Loading