Skip to content

Commit

Permalink
Merge pull request #112 from sandydoo/fix-modifier-manager-deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
sandydoo authored May 29, 2021
2 parents 8b11f0d + 5789851 commit 57b8ef9
Show file tree
Hide file tree
Showing 10 changed files with 233 additions and 18 deletions.
2 changes: 1 addition & 1 deletion addon/components/g-map/autocomplete.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{#if (has-block)}}
{{yield (hash setup=this.getInput)}}
{{else}}
<input id={{this.id}} ...attributes {{did-insert this.getInput}} />
<input id={{this.id}} ...attributes {{g-map/did-insert this.getInput}} />
{{/if}}
2 changes: 1 addition & 1 deletion addon/components/g-map/canvas.hbs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<div id={{@id}} class="ember-google-map" ...attributes {{did-insert @onCanvasReady}}>{{yield}}</div>
<div id={{@id}} class="ember-google-map" ...attributes {{g-map/did-insert @onCanvasReady}}>{{yield}}</div>
2 changes: 1 addition & 1 deletion addon/components/g-map/control.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{#if this.container}}
{{#in-element this.container}}
{{!-- Compatibility: @classNames should be deprecated --}}
<div id={{this.id}} class={{@classNames}} ...attributes {{did-insert this.getControl}}>{{yield}}</div>
<div id={{this.id}} class={{@classNames}} ...attributes {{g-map/did-insert this.getControl}}>{{yield}}</div>
{{/in-element}}
{{/if}}
2 changes: 1 addition & 1 deletion addon/components/g-map/overlay.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{#if (has-block)}}
{{#if this.container}}
{{#in-element this.container}}
<div id={{this.id}} ...attributes {{did-insert this.getOverlay}}>{{yield}}</div>
<div id={{this.id}} ...attributes {{g-map/did-insert this.getOverlay}}>{{yield}}</div>
{{/in-element}}
{{/if}}
{{/if}}
15 changes: 15 additions & 0 deletions addon/modifiers/g-map/did-insert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { modifier } from 'ember-modifier';
import { assert } from '@ember/debug';

export default modifier(function gMapDidInsert(
element,
[callback, ...positional],
named
) {
assert(
'`g-map/did-insert` expects a function as its first positional argument.',
typeof callback === 'function'
);

callback(element, positional, named);
});
1 change: 1 addition & 0 deletions app/modifiers/g-map/did-insert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from 'ember-google-maps/modifiers/g-map/did-insert';
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"test:build": "node build-tests/build-test"
},
"dependencies": {
"@ember/render-modifiers": "^1.0.2",
"babel-plugin-ember-modules-api-polyfill": ">=3.5.0",
"broccoli-debug": "^0.6.5",
"broccoli-funnel": ">=2.0.0",
Expand All @@ -51,6 +50,7 @@
"ember-cli-htmlbars": "^5.3.2",
"ember-concurrency": "^2.0.0",
"ember-in-element-polyfill": "^1.0.0",
"ember-modifier": "^2.1.2",
"tracked-toolbox": "^1.2.2"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/components/g-map/autocomplete-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module('Integration | Component | g map/autocomplete', function (hooks) {
await render(hbs`
<GMap @lat={{this.lat}} @lng={{this.lng}} as |g|>
<g.autocomplete as |autocomplete|>
<input {{did-insert autocomplete.setup}} />
<input {{g-map/did-insert autocomplete.setup}} />
</g.autocomplete>
</GMap>
`);
Expand Down
22 changes: 22 additions & 0 deletions tests/integration/modifiers/g-map/did-insert-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';

module('Integration | Modifier | g-map/did-insert', function (hooks) {
setupRenderingTest(hooks);

test('it works', async function (assert) {
assert.expect(3);

this.onDidInsert = (element, positional, named) => {
assert.ok(element instanceof Element, 'passes the element');
assert.equal(positional.length, 1, 'passes positional args');
assert.equal(Object.keys(named).length, 1, 'passes named args');
};

await render(hbs`
<div {{g-map/did-insert this.onDidInsert "positonal arg" oneMoreThing="named arg" }}></div>
`);
});
});
Loading

0 comments on commit 57b8ef9

Please sign in to comment.