|
1 | 1 | import { setModifierManager, capabilities } from '@ember/modifier'; |
2 | | -import { |
3 | | - macroCondition, |
4 | | - dependencySatisfies, |
5 | | - importSync, |
6 | | -} from '@embroider/macros'; |
7 | | - |
8 | | -const untrack = (function () { |
9 | | - if (macroCondition(dependencySatisfies('ember-source', '> 3.27.0-beta.1'))) { |
10 | | - // ember-source@3.27 shipped "real modules" by default, so we can just use |
11 | | - // importSync to get @glimmer/validator directly |
12 | | - return importSync('@glimmer/validator').untrack; |
13 | | - } else if ( |
14 | | - macroCondition(dependencySatisfies('ember-source', '>= 3.22.0-alpha.1')) |
15 | | - ) { |
16 | | - // we can access `window.Ember` here because it wasn't deprecated until at least 3.27 |
17 | | - // eslint-disable-next-line no-undef |
18 | | - return Ember.__loader.require('@glimmer/validator').untrack; |
19 | | - } else { |
20 | | - // nothing needed here, we do not call `untrack` in this case |
21 | | - } |
22 | | -})(); |
| 2 | +import { untrack } from '@glimmer/validator'; |
23 | 3 |
|
24 | 4 | /** |
25 | 5 | The `{{did-update}}` element modifier is activated when any of its arguments |
@@ -79,47 +59,32 @@ const untrack = (function () { |
79 | 59 | */ |
80 | 60 | export default setModifierManager( |
81 | 61 | () => ({ |
82 | | - capabilities: macroCondition( |
83 | | - dependencySatisfies('ember-source', '>= 3.22.0-alpha.1'), |
84 | | - ) |
85 | | - ? capabilities('3.22', { disableAutoTracking: false }) |
86 | | - : capabilities('3.13', { disableAutoTracking: true }), |
87 | | - |
| 62 | + capabilities: capabilities('3.22', { disableAutoTracking: false }), |
88 | 63 | createModifier() { |
89 | 64 | return { element: null }; |
90 | 65 | }, |
91 | 66 | installModifier(state, element, args) { |
92 | 67 | // save element into state bucket |
93 | 68 | state.element = element; |
94 | 69 |
|
95 | | - if ( |
96 | | - macroCondition(dependencySatisfies('ember-source', '>= 3.22.0-alpha.1')) |
97 | | - ) { |
98 | | - // Consume individual properties to entangle tracking. |
99 | | - // https://github.com/emberjs/ember.js/issues/19277 |
100 | | - // https://github.com/ember-modifier/ember-modifier/pull/63#issuecomment-815908201 |
101 | | - args.positional.forEach(() => {}); |
102 | | - args.named && Object.values(args.named); |
103 | | - } |
| 70 | + // Consume individual properties to entangle tracking. |
| 71 | + // https://github.com/emberjs/ember.js/issues/19277 |
| 72 | + // https://github.com/ember-modifier/ember-modifier/pull/63#issuecomment-815908201 |
| 73 | + args.positional.forEach(() => {}); |
| 74 | + args.named && Object.values(args.named); |
104 | 75 | }, |
105 | 76 |
|
106 | 77 | updateModifier({ element }, args) { |
107 | 78 | let [fn, ...positional] = args.positional; |
108 | 79 |
|
109 | | - if ( |
110 | | - macroCondition(dependencySatisfies('ember-source', '>= 3.22.0-alpha.1')) |
111 | | - ) { |
112 | | - // Consume individual properties to entangle tracking. |
113 | | - // https://github.com/emberjs/ember.js/issues/19277 |
114 | | - // https://github.com/ember-modifier/ember-modifier/pull/63#issuecomment-815908201 |
115 | | - args.positional.forEach(() => {}); |
116 | | - args.named && Object.values(args.named); |
117 | | - untrack(() => { |
118 | | - fn(element, positional, args.named); |
119 | | - }); |
120 | | - } else { |
| 80 | + // Consume individual properties to entangle tracking. |
| 81 | + // https://github.com/emberjs/ember.js/issues/19277 |
| 82 | + // https://github.com/ember-modifier/ember-modifier/pull/63#issuecomment-815908201 |
| 83 | + args.positional.forEach(() => {}); |
| 84 | + args.named && Object.values(args.named); |
| 85 | + untrack(() => { |
121 | 86 | fn(element, positional, args.named); |
122 | | - } |
| 87 | + }); |
123 | 88 | }, |
124 | 89 |
|
125 | 90 | destroyModifier() {}, |
|
0 commit comments