diff --git a/.eslintrc.js b/.eslintrc.js index 27839417..d5edecdc 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -7,13 +7,13 @@ module.exports = { ecmaVersion: 2018, sourceType: 'module', ecmaFeatures: { - legacyDecorators: true - } + legacyDecorators: true, + }, }, plugins: ['ember'], extends: ['eslint:recommended', 'plugin:ember/recommended'], env: { - browser: true + browser: true, }, rules: {}, overrides: [ @@ -27,7 +27,6 @@ module.exports = { 'index.js', 'testem.js', 'config/**/*.js', - 'lib/**/*.js', 'tests/dummy/config/**/*.js', ], excludedFiles: [ @@ -37,14 +36,14 @@ module.exports = { 'tests/dummy/app/**', ], parserOptions: { - sourceType: 'script' + sourceType: 'script', }, env: { browser: false, node: true, }, plugins: ['node'], - extends: ['plugin:node/recommended'] - } - ] + extends: ['plugin:node/recommended'], + }, + ], }; diff --git a/README.md b/README.md index 808f34c0..6825a3e7 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,9 @@ ember install ember-page-title ### Compatibility -* Ember.js v3.12 or above -* Ember CLI v2.13 or above -* Node.js v10 or above +- Ember.js v3.12 or above +- Ember CLI v2.13 or above +- Node.js v10 or above
Fastboot vs Non-Fastboot Notes @@ -61,13 +61,13 @@ module.exports = function (environment) { ### Deprecations - Since **v5.2.2**: The `{{title}}` helper has been deprecated, use `{{page-title}}` instead, it has the same API. The - `{{title}}` helper was an AST transform and will be removed in the next major release. + `{{title}}` helper was an AST transform and was removed in **v6.0.0**. ### Upgrading notes for 5.x to 6.x -`ember-page-title` no longer requires the usage of `ember-cli-head`. - -Please remove `{{head-layout}}` from your application's `application.hbs` route template. +- `ember-page-title` no longer requires the usage of `ember-cli-head`. + Please remove `{{head-layout}}` from your application's `application.hbs` route template. +- `{{title}}` has been removed, please rename to `{{page-title}}`. ### Upgrading notes for 3.x to 4.x diff --git a/addon/helpers/page-title.js b/addon/helpers/page-title.js index 44aec060..a253edba 100644 --- a/addon/helpers/page-title.js +++ b/addon/helpers/page-title.js @@ -4,7 +4,7 @@ import { guidFor } from '@ember/object/internals'; import { assign } from '@ember/polyfills'; /** - `{{page-title}}` is used to communicate with + `{{page-title}}` helper used to set the title of the current route context. @public @method page-title @@ -22,22 +22,10 @@ export default Helper.extend({ }, compute(params, _hash) { - // page-title used via title ast transform, which is deprecated - if (_hash && _hash._deprecate) { - // eslint-disable-next-line no-console - console.warn( - 'Using `{{title}}` helper is deprecated, use `{{page-title}}` instead. ' + - _hash._deprecate - ); - } - let hash = assign( - {}, - _hash, - { - id: this.tokenId, - title: params.join('') - } - ); + let hash = assign({}, _hash, { + id: this.tokenId, + title: params.join(''), + }); this.tokens.push(hash); this.tokens.scheduleTitleUpdate(); diff --git a/addon/services/page-title-list.js b/addon/services/page-title-list.js index d8e93692..06fdfbc5 100644 --- a/addon/services/page-title-list.js +++ b/addon/services/page-title-list.js @@ -124,7 +124,7 @@ export default Service.extend({ remove(id) { let token = this.tokens.findBy('id', id); - let {next, previous} = token; + let { next, previous } = token; if (next) { next.previous = previous; } @@ -143,7 +143,7 @@ export default Service.extend({ visibleTokens: computed('tokens', { get() { let tokens = this.tokens; - let i = (tokens ? tokens.length : 0); + let i = tokens ? tokens.length : 0; let visible = []; while (i--) { let token = tokens[i]; @@ -155,7 +155,7 @@ export default Service.extend({ } } return visible; - } + }, }), sortedTokens: computed('visibleTokens', { @@ -193,7 +193,7 @@ export default Service.extend({ return frontGroups.concat( groups.reduce((E, group) => E.concat(group), []) ); - } + }, }), scheduleTitleUpdate() { @@ -243,5 +243,5 @@ export default Service.extend({ let title = titles[i]; title.parentNode.removeChild(title); } - } + }, }); diff --git a/index.js b/index.js index f52ce3bc..0ca063d4 100644 --- a/index.js +++ b/index.js @@ -1,27 +1,5 @@ 'use strict'; module.exports = { - name: 'ember-page-title', - - setupPreprocessorRegistry(_, registry) { - const plugin = this._buildPlugin(); - - plugin.parallelBabel = { - requireFile: __filename, - buildUsing: '_buildPlugin', - params: {} - }; - - registry.add('htmlbars-ast-plugin', plugin); - }, - - _buildPlugin() { - return { - name: 'translate-title-helper-to-page-title-helper', - plugin: require('./lib/plugins/translate-helper-name'), - baseDir() { - return __dirname; - } - }; - } + name: require('./package').name, }; diff --git a/lib/plugins/translate-helper-name.js b/lib/plugins/translate-helper-name.js deleted file mode 100644 index 8b52f62b..00000000 --- a/lib/plugins/translate-helper-name.js +++ /dev/null @@ -1,31 +0,0 @@ -function TranslateHelperName(options) { - this.syntax = null; - this.options = options; -} - -TranslateHelperName.prototype.transform = function TranslateHelperName_transform( - ast -) { - var b = this.syntax.builders; - var walker = new this.syntax.Walker(); - - walker.visit(ast, function (node) { - if (!validate(node)) { - return; - } - node.path = b.path('page-title'); - node.hash.pairs.push(b.pair('_deprecate', b.string(node.loc.source))); - }); - - return ast; -}; - -function validate(node) { - return ( - node.type === 'MustacheStatement' && - node.path.original === 'title' && - node.params.length > 0 - ); -} - -module.exports = TranslateHelperName;