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

Remove -in-element #19644

Merged
merged 2 commits into from Jul 18, 2021
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

This file was deleted.

@@ -1,6 +1,5 @@
import { assert, deprecate } from '@ember/debug';
import { assert } from '@ember/debug';
import { AST, ASTPlugin } from '@glimmer/syntax';
import calculateLocationDisplay from '../system/calculate-location-display';
import { EmberASTPluginEnvironment } from '../types';
import { isPath } from './utils';

Expand All @@ -9,26 +8,7 @@ import { isPath } from './utils';
*/

/**
A Glimmer2 AST transformation that handles the public `{{in-element}}` as per RFC287, and deprecates but still
continues support for the private `{{-in-element}}`.
Transforms:
```handlebars
{{#-in-element someElement}}
{{modal-display text=text}}
{{/-in-element}}
```
into:
```handlebars
{{#in-element someElement}}
{{modal-display text=text}}
{{/in-element}}
```
And issues a deprecation message.
A Glimmer2 AST transformation that handles the public `{{in-element}}` as per RFC287.
Issues a build time assertion for:
Expand All @@ -42,7 +22,6 @@ import { isPath } from './utils';
@class TransformInElement
*/
export default function transformInElement(env: EmberASTPluginEnvironment): ASTPlugin {
let moduleName = env.meta?.moduleName;
let { builders: b } = env.syntax;

return {
Expand Down Expand Up @@ -72,47 +51,6 @@ export default function transformInElement(env: EmberASTPluginEnvironment): ASTP
);
}
});
} else if (node.path.original === '-in-element') {
let sourceInformation = calculateLocationDisplay(moduleName, node.loc);
deprecate(
`The use of the private \`{{-in-element}}\` is deprecated, please refactor to the public \`{{in-element}}\`. ${sourceInformation}`,
false,
{
id: 'glimmer.private-in-element',
until: '3.25.0',
for: 'ember-source',
since: {
enabled: '3.20.0',
},
}
);

node.path.original = 'in-element';
node.path.parts = ['in-element'];

// replicate special hash arguments added here:
// https://github.com/glimmerjs/glimmer-vm/blob/ba9b37d44b85fa1385eeeea71910ff5798198c8e/packages/%40glimmer/syntax/lib/parser/handlebars-node-visitors.ts#L340-L363
let needsInsertBefore = true;
let hash = node.hash;
hash.pairs.forEach((pair) => {
if (pair.key === 'insertBefore') {
assert(
`Can only pass a null or undefined literals to insertBefore in -in-element, received: ${JSON.stringify(
pair.value
)}`,
pair.value.type === 'NullLiteral' || pair.value.type === 'UndefinedLiteral'
);

needsInsertBefore = false;
}
});

// Maintain compatibility with previous -in-element behavior (defaults to append, not clear)
if (needsInsertBefore) {
let nullLiteral = b.literal('NullLiteral', null);
let nextSibling = b.pair('insertBefore', nullLiteral);
hash.pairs.push(nextSibling);
}
}
},
},
Expand Down