Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AST deprecation not implemented yet.
- Loading branch information
Miguel Camba
committed
Jun 14, 2018
1 parent
53d8e36
commit 1d5687a
Showing
3 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
packages/ember-template-compiler/lib/plugins/deprecate-send-action.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { deprecate } from '@ember/debug'; | ||
import { AST, ASTPlugin, ASTPluginEnvironment } from '@glimmer/syntax'; | ||
import calculateLocationDisplay from '../system/calculate-location-display'; | ||
|
||
export default function deprecateRender(env: ASTPluginEnvironment): ASTPlugin | undefined { | ||
// let { moduleName } = env.meta; | ||
|
||
// let deprecationMessage = (node: AST.MustacheStatement) => { | ||
// let sourceInformation = calculateLocationDisplay(moduleName, node.loc); | ||
// let componentName = (node.params[0] as AST.PathExpression).original; | ||
// let original = `{{render "${componentName}"}}`; | ||
// let preferred = `{{${componentName}}}`; | ||
|
||
// return ( | ||
// `Please refactor \`${original}\` to a component and invoke via` + | ||
// ` \`${preferred}\`. ${sourceInformation}` | ||
// ); | ||
// }; | ||
|
||
// return { | ||
// name: 'deprecate-render', | ||
|
||
// visitor: { | ||
// MustacheStatement(node: AST.MustacheStatement) { | ||
// if (node.path.original !== 'render') { | ||
// return; | ||
// } | ||
// if (node.params.length !== 1) { | ||
// return; | ||
// } | ||
|
||
// node.params.forEach(param => { | ||
// if (param.type !== 'StringLiteral') { | ||
// return; | ||
// } | ||
|
||
// deprecate(deprecationMessage(node), false, { | ||
// id: 'ember-template-compiler.deprecate-render', | ||
// until: '3.0.0', | ||
// url: 'https://emberjs.com/deprecations/v2.x#toc_code-render-code-helper', | ||
// }); | ||
// }); | ||
// }, | ||
// }, | ||
// }; | ||
} |
27 changes: 27 additions & 0 deletions
27
packages/ember-template-compiler/tests/plugins/deprecate-send-action.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { compile } from '../../index'; | ||
import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; | ||
|
||
const EVENTS = [ | ||
'insert-newline', | ||
'enter', | ||
'escape-press', | ||
'focus-in', | ||
'focus-out', | ||
'key-press', | ||
'key-up', | ||
'key-down', | ||
]; | ||
|
||
class DeprecateSendActionTest extends AbstractTestCase {} | ||
EVENTS.forEach(function(e) { | ||
DeprecateSendActionTest.prototype[ | ||
`@test Using \`{{input ${e}="actionName"}}\` provides a deprecation` | ||
] = function() { | ||
let expectedMessage = `Please refactor \`{{input ${e}="foo-bar"}}\` to \`{{input ${e}=(action "foo-bar")}}\. ('baz/foo-bar' @ L1:C0)`; | ||
|
||
expectDeprecation(() => { | ||
compile(`{{input ${e}="foo-bar"}}`, { moduleName: 'baz/foo-bar' }); | ||
}, expectedMessage); | ||
}; | ||
}); | ||
moduleFor('ember-template-compiler: deprecate-send-action', DeprecateSendActionTest); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters