├── .editorconfig ├── .ember-cli ├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── .npmignore ├── .template-lintrc.js ├── .travis.yml ├── .watchmanconfig ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── addon └── helpers │ └── set.js ├── app └── helpers │ └── set.js ├── config ├── ember-try.js └── environment.js ├── ember-cli-build.js ├── index.js ├── lib └── simple-set-transform.js ├── package.json ├── testem.js ├── tests ├── dummy │ ├── app │ │ ├── app.js │ │ ├── components │ │ │ ├── counter.js │ │ │ └── parent.js │ │ ├── controllers │ │ │ └── application.js │ │ ├── helpers │ │ │ └── .gitkeep │ │ ├── index.html │ │ ├── models │ │ │ └── user.js │ │ ├── router.js │ │ ├── routes │ │ │ └── .gitkeep │ │ ├── styles │ │ │ └── app.css │ │ └── templates │ │ │ ├── application.hbs │ │ │ └── components │ │ │ ├── child.hbs │ │ │ ├── counter.hbs │ │ │ └── parent.hbs │ ├── config │ │ ├── environment.js │ │ ├── optional-features.json │ │ └── targets.js │ └── public │ │ └── robots.txt ├── helpers │ └── .gitkeep ├── index.html ├── integration │ └── helpers │ │ └── set-test.js ├── test-helper.js └── unit │ └── .gitkeep ├── vendor └── .gitkeep └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | [*] 8 | end_of_line = lf 9 | charset = utf-8 10 | trim_trailing_whitespace = true 11 | insert_final_newline = true 12 | indent_style = space 13 | indent_size = 2 14 | 15 | [*.hbs] 16 | insert_final_newline = false 17 | 18 | [*.{diff,md}] 19 | trim_trailing_whitespace = false 20 | -------------------------------------------------------------------------------- /.ember-cli: -------------------------------------------------------------------------------- 1 | { 2 | /** 3 | Ember CLI sends analytics information by default. The data is completely 4 | anonymous, but there are times when you might want to disable this behavior. 5 | 6 | Setting `disableAnalytics` to true will prevent any data from being sent. 7 | */ 8 | "disableAnalytics": false 9 | } 10 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | # unconventional js 2 | /blueprints/*/files/ 3 | /vendor/ 4 | 5 | # compiled output 6 | /dist/ 7 | /tmp/ 8 | 9 | # dependencies 10 | /bower_components/ 11 | /node_modules/ 12 | 13 | # misc 14 | /coverage/ 15 | !.* 16 | 17 | # ember-try 18 | /.node_modules.ember-try/ 19 | /bower.json.ember-try 20 | /package.json.ember-try 21 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | parser: 'babel-eslint', 4 | parserOptions: { 5 | ecmaVersion: 2018, 6 | sourceType: 'module', 7 | ecmaFeatures: { 8 | legacyDecorators: true 9 | } 10 | }, 11 | plugins: [ 12 | 'ember' 13 | ], 14 | extends: [ 15 | 'eslint:recommended', 16 | 'plugin:ember/recommended' 17 | ], 18 | env: { 19 | browser: true 20 | }, 21 | rules: { 22 | 'ember/no-jquery': 'error' 23 | }, 24 | overrides: [ 25 | // node files 26 | { 27 | files: [ 28 | '.eslintrc.js', 29 | '.template-lintrc.js', 30 | 'ember-cli-build.js', 31 | 'index.js', 32 | 'testem.js', 33 | 'blueprints/*/index.js', 34 | 'config/**/*.js', 35 | 'tests/dummy/config/**/*.js' 36 | ], 37 | excludedFiles: [ 38 | 'addon/**', 39 | 'addon-test-support/**', 40 | 'app/**', 41 | 'tests/dummy/app/**' 42 | ], 43 | parserOptions: { 44 | sourceType: 'script' 45 | }, 46 | env: { 47 | browser: false, 48 | node: true 49 | }, 50 | plugins: ['node'], 51 | rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, { 52 | // add your custom rules and overrides for node files here 53 | }) 54 | } 55 | ] 56 | }; 57 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist/ 5 | /tmp/ 6 | 7 | # dependencies 8 | /bower_components/ 9 | /node_modules/ 10 | 11 | # misc 12 | /.env* 13 | /.pnp* 14 | /.sass-cache 15 | /connect.lock 16 | /coverage/ 17 | /libpeerconnection.log 18 | /npm-debug.log* 19 | /testem.log 20 | /yarn-error.log 21 | 22 | # ember-try 23 | /.node_modules.ember-try/ 24 | /bower.json.ember-try 25 | /package.json.ember-try 26 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # compiled output 2 | /dist/ 3 | /tmp/ 4 | 5 | # dependencies 6 | /bower_components/ 7 | 8 | # misc 9 | /.bowerrc 10 | /.editorconfig 11 | /.ember-cli 12 | /.env* 13 | /.eslintignore 14 | /.eslintrc.js 15 | /.git/ 16 | /.gitignore 17 | /.template-lintrc.js 18 | /.travis.yml 19 | /.watchmanconfig 20 | /bower.json 21 | /config/ember-try.js 22 | /CONTRIBUTING.md 23 | /ember-cli-build.js 24 | /testem.js 25 | /tests/ 26 | /yarn.lock 27 | .gitkeep 28 | 29 | # ember-try 30 | /.node_modules.ember-try/ 31 | /bower.json.ember-try 32 | /package.json.ember-try 33 | -------------------------------------------------------------------------------- /.template-lintrc.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: 'octane' 5 | }; 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | language: node_js 3 | node_js: 4 | # we recommend testing addons with the same minimum supported node version as Ember CLI 5 | # so that your addon works for all apps 6 | - "10" 7 | 8 | dist: trusty 9 | 10 | addons: 11 | chrome: stable 12 | 13 | cache: 14 | directories: 15 | - $HOME/.npm 16 | 17 | env: 18 | global: 19 | # See https://git.io/vdao3 for details. 20 | - JOBS=1 21 | 22 | branches: 23 | only: 24 | - master 25 | # npm version tags 26 | - /^v\d+\.\d+\.\d+/ 27 | 28 | jobs: 29 | fast_finish: true 30 | allow_failures: 31 | - env: EMBER_TRY_SCENARIO=ember-canary 32 | 33 | include: 34 | # runs linting and tests with current locked deps 35 | - stage: "Tests" 36 | name: "Tests" 37 | script: 38 | - npm run lint:hbs 39 | - npm run lint:js 40 | - npm test 41 | 42 | - stage: "Additional Tests" 43 | name: "Floating Dependencies" 44 | install: 45 | - npm install --no-package-lock 46 | script: 47 | - npm test 48 | 49 | # we recommend new addons test the current and previous LTS 50 | # as well as latest stable release (bonus points to beta/canary) 51 | - env: EMBER_TRY_SCENARIO=ember-lts-3.12 52 | - env: EMBER_TRY_SCENARIO=ember-release 53 | - env: EMBER_TRY_SCENARIO=ember-beta 54 | - env: EMBER_TRY_SCENARIO=ember-canary 55 | - env: EMBER_TRY_SCENARIO=ember-default-with-jquery 56 | - env: EMBER_TRY_SCENARIO=ember-classic 57 | 58 | script: 59 | - node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO 60 | -------------------------------------------------------------------------------- /.watchmanconfig: -------------------------------------------------------------------------------- 1 | { 2 | "ignore_dirs": ["tmp", "dist"] 3 | } 4 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How To Contribute 2 | 3 | ## Installation 4 | 5 | * `git clone ` 6 | * `cd ember-simple-set-helper` 7 | * `yarn install` 8 | 9 | ## Linting 10 | 11 | * `yarn lint:hbs` 12 | * `yarn lint:js` 13 | * `yarn lint:js --fix` 14 | 15 | ## Running tests 16 | 17 | * `ember test` – Runs the test suite on the current Ember version 18 | * `ember test --server` – Runs the test suite in "watch mode" 19 | * `ember try:each` – Runs the test suite against multiple Ember versions 20 | 21 | ## Running the dummy application 22 | 23 | * `ember serve` 24 | * Visit the dummy application at [http://localhost:4200](http://localhost:4200). 25 | 26 | For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/). -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2020 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ember-simple-set-helper 2 | 3 | **NOTE: This addon is deprecated in favor of [ember-set-helper](https://github.com/pzuraq/ember-set-helper)** 4 | 5 | --- 6 | 7 | A(nother) better `mut` helper! 8 | 9 | ```hbs 10 | {{this.greeting}} 11 | 12 | 15 | 16 | 19 | ``` 20 | 21 | This addon is a more direct replacement for Ember's `mut` helper than other 22 | alternatives (such as [ember-set-helper](https://github.com/pzuraq/ember-set-helper)). 23 | 24 | ## Usage 25 | 26 | The `{{set}}` helper returns a function that sets a value. This can be used in 27 | combination with Ember's `{{on}}` modifier or component actions to update state 28 | without having to write your own custom action. For simple cases, this is pretty 29 | handy: 30 | 31 | ```hbs 32 | 35 | ``` 36 | 37 | ### Setting Passed Values 38 | 39 | If you do not provide a value to the `set` helper, it will set the value that is 40 | provided to it when called. For example: 41 | 42 | ```hbs 43 | 44 | {{this.count}} 45 | 46 | 47 | ``` 48 | 49 | ```js 50 | // app/components/counter.js 51 | import Component from '@glimmer/component'; 52 | import { tracked } from '@glimmer/tracking'; 53 | import { action } from '@ember/object'; 54 | 55 | export default class Counter extends Component { 56 | @tracked count = 0; 57 | 58 | @action 59 | updateCount() { 60 | this.count++; 61 | 62 | if (this.args.onClick) { 63 | this.args.onClick(this.count); 64 | } 65 | } 66 | } 67 | ``` 68 | 69 | ```hbs 70 | 71 | 72 | ``` 73 | 74 | This will set the value of `this.currentCount` to whatever value is passed to it 75 | when it is called (in this case the `count` of the counter component whenever a 76 | user clicks the button). 77 | 78 | ### Differences from `mut` 79 | 80 | - No need to call wrap the helper (e.g. `(set this.foo)` === `(fn (mut this.foo))`) 81 | - Optional last parameter if setting a static value (e.g. `(set this.foo "bar")` === `(fn (mut this.foo) "bar")`) 82 | - Cannot be used as both a getter and setter for the value, only provides a setter 83 | 84 | ### Differences from `ember-set-helper` 85 | 86 | - No ability to use placeholder syntax 87 | 88 | ## Compatibility 89 | 90 | - Ember.js v3.4 or above 91 | - Ember CLI v2.13 or above 92 | - Node.js v8 or above 93 | 94 | ## Installation 95 | 96 | ``` 97 | ember install ember-simple-set-helper 98 | ``` 99 | 100 | ## Contributing 101 | 102 | See the [Contributing](CONTRIBUTING.md) guide for details. 103 | 104 | ## License 105 | 106 | This project is licensed under the [MIT License](LICENSE.md). 107 | -------------------------------------------------------------------------------- /addon/helpers/set.js: -------------------------------------------------------------------------------- 1 | import { helper } from '@ember/component/helper'; 2 | import { assert } from '@ember/debug'; 3 | import { set as emberSet } from '@ember/object'; 4 | 5 | function set(positional) { 6 | let [target, key, maybeValue] = positional; 7 | assert( 8 | 'you must pass a path to {{set}}', 9 | (Boolean(target) && typeof key === 'string') || typeof key === 'symbol' 10 | ); 11 | 12 | return positional.length === 3 13 | ? () => emberSet(target, key, maybeValue) 14 | : value => emberSet(target, key, value); 15 | } 16 | 17 | export default helper(set); 18 | -------------------------------------------------------------------------------- /app/helpers/set.js: -------------------------------------------------------------------------------- 1 | export { default } from 'ember-simple-set-helper/helpers/set'; 2 | -------------------------------------------------------------------------------- /config/ember-try.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const getChannelURL = require('ember-source-channel-url'); 4 | 5 | module.exports = async function() { 6 | return { 7 | scenarios: [ 8 | { 9 | name: 'ember-lts-3.12', 10 | npm: { 11 | devDependencies: { 12 | 'ember-source': '~3.12.0' 13 | } 14 | } 15 | }, 16 | { 17 | name: 'ember-lts-3.16', 18 | npm: { 19 | devDependencies: { 20 | 'ember-source': '~3.16.0' 21 | } 22 | } 23 | }, 24 | { 25 | name: 'ember-release', 26 | npm: { 27 | devDependencies: { 28 | 'ember-source': await getChannelURL('release') 29 | } 30 | } 31 | }, 32 | { 33 | name: 'ember-beta', 34 | npm: { 35 | devDependencies: { 36 | 'ember-source': await getChannelURL('beta') 37 | } 38 | } 39 | }, 40 | { 41 | name: 'ember-canary', 42 | npm: { 43 | devDependencies: { 44 | 'ember-source': await getChannelURL('canary') 45 | } 46 | } 47 | }, 48 | // The default `.travis.yml` runs this scenario via `npm test`, 49 | // not via `ember try`. It's still included here so that running 50 | // `ember try:each` manually or from a customized CI config will run it 51 | // along with all the other scenarios. 52 | { 53 | name: 'ember-default', 54 | npm: { 55 | devDependencies: {} 56 | } 57 | }, 58 | { 59 | name: 'ember-default-with-jquery', 60 | env: { 61 | EMBER_OPTIONAL_FEATURES: JSON.stringify({ 62 | 'jquery-integration': true 63 | }) 64 | }, 65 | npm: { 66 | devDependencies: { 67 | '@ember/jquery': '^0.5.1' 68 | } 69 | } 70 | }, 71 | { 72 | name: 'ember-classic', 73 | env: { 74 | EMBER_OPTIONAL_FEATURES: JSON.stringify({ 75 | 'application-template-wrapper': true, 76 | 'default-async-observers': false, 77 | 'template-only-glimmer-components': false 78 | }) 79 | }, 80 | npm: { 81 | ember: { 82 | edition: 'classic' 83 | } 84 | } 85 | } 86 | ] 87 | }; 88 | }; 89 | -------------------------------------------------------------------------------- /config/environment.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function(/* environment, appConfig */) { 4 | return { }; 5 | }; 6 | -------------------------------------------------------------------------------- /ember-cli-build.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const EmberAddon = require('ember-cli/lib/broccoli/ember-addon'); 4 | 5 | module.exports = function(defaults) { 6 | let app = new EmberAddon(defaults, { 7 | // Add options here 8 | }); 9 | 10 | /* 11 | This build file specifies the options for the dummy test app of this 12 | addon, located in `/tests/dummy` 13 | This build file does *not* influence how the addon or the app using it 14 | behave. You most likely want to be modifying `./index.js` or app's build file 15 | */ 16 | 17 | return app.toTree(); 18 | }; 19 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | name: require('./package').name, 5 | 6 | setupPreprocessorRegistry(type, registry) { 7 | const plugin = this._buildPlugin(); 8 | 9 | plugin.parallelBabel = { 10 | requireFile: __filename, 11 | buildUsing: '_buildPlugin', 12 | params: {} 13 | }; 14 | 15 | registry.add('htmlbars-ast-plugin', plugin); 16 | }, 17 | 18 | _buildPlugin() { 19 | const SimpleSetTransform = require('./lib/simple-set-transform'); 20 | 21 | return { 22 | name: 'set-placeholder', 23 | plugin: SimpleSetTransform, 24 | baseDir() { 25 | return __dirname; 26 | } 27 | }; 28 | } 29 | }; -------------------------------------------------------------------------------- /lib/simple-set-transform.js: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | 'use strict'; 3 | 4 | /* 5 | ```hbs 6 | {{set this.bar}} 7 | {{set this.bar "baz"}} 8 | ``` 9 | 10 | becomes 11 | 12 | ```hbs 13 | {{set this "bar"}} 14 | {{set this "bar" "baz"}} 15 | ``` 16 | */ 17 | 18 | module.exports = class SetTransform { 19 | transform(ast) { 20 | let b = this.syntax.builders; 21 | 22 | function transformNode(node) { 23 | if (node.path.original === 'set') { 24 | if (!node.params[0] || node.params[0].type !== 'PathExpression') { 25 | throw new Error( 26 | 'the (set) helper requires a path to be passed in as its first parameter, received: ' + 27 | path.original 28 | ); 29 | } 30 | 31 | if (node.params.length > 2) { 32 | throw new Error( 33 | 'the (set) helper can only recieve 2 arguments at most, recieved: ' + 34 | node.params.length 35 | ); 36 | } 37 | 38 | let path = node.params.shift(); 39 | 40 | let splitPoint = path.original.lastIndexOf('.'); 41 | 42 | let key = path.original.substr(splitPoint + 1); 43 | 44 | let targetName = 45 | splitPoint === -1 ? 'this' : path.original.substr(0, splitPoint); 46 | 47 | let target; 48 | 49 | if (targetName[0] === '@') { 50 | target = b.path(targetName.slice(1)); 51 | target.data = true; 52 | } else { 53 | target = b.path(targetName); 54 | } 55 | 56 | node.params.unshift(target, b.string(key)); 57 | 58 | // console.log(node); 59 | } 60 | } 61 | 62 | this.syntax.traverse(ast, { 63 | SubExpression: transformNode, 64 | MustacheStatement: transformNode, 65 | }); 66 | 67 | return ast; 68 | } 69 | }; 70 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember-simple-set-helper", 3 | "version": "0.1.2", 4 | "description": "A(nother) better `mut` helper!", 5 | "keywords": [ 6 | "ember-addon" 7 | ], 8 | "repository": "https://github.com/pzuraq/ember-simple-set-helper", 9 | "license": "MIT", 10 | "author": "Chris Garrett", 11 | "directories": { 12 | "doc": "doc", 13 | "test": "tests" 14 | }, 15 | "scripts": { 16 | "build": "ember build --environment=production", 17 | "lint:hbs": "ember-template-lint .", 18 | "lint:js": "eslint .", 19 | "start": "ember serve", 20 | "test": "ember test", 21 | "test:all": "ember try:each" 22 | }, 23 | "dependencies": { 24 | "ember-cli-babel": "^7.17.2", 25 | "ember-cli-htmlbars": "^4.2.2" 26 | }, 27 | "devDependencies": { 28 | "@ember/optional-features": "^1.3.0", 29 | "@glimmer/component": "^1.0.0", 30 | "@glimmer/tracking": "^1.0.0", 31 | "babel-eslint": "^10.0.3", 32 | "broccoli-asset-rev": "^3.0.0", 33 | "ember-auto-import": "^1.5.3", 34 | "ember-cli": "~3.16.0", 35 | "ember-cli-dependency-checker": "^3.2.0", 36 | "ember-cli-eslint": "^5.1.0", 37 | "ember-cli-inject-live-reload": "^2.0.2", 38 | "ember-cli-sri": "^2.1.1", 39 | "ember-cli-template-lint": "^1.0.0-beta.3", 40 | "ember-cli-uglify": "^3.0.0", 41 | "ember-disable-prototype-extensions": "^1.1.3", 42 | "ember-export-application-global": "^2.0.1", 43 | "ember-load-initializers": "^2.1.1", 44 | "ember-maybe-import-regenerator": "^0.1.6", 45 | "ember-qunit": "^4.6.0", 46 | "ember-resolver": "^7.0.0", 47 | "ember-source": "~3.16.3", 48 | "ember-source-channel-url": "^2.0.1", 49 | "ember-try": "^1.4.0", 50 | "eslint-plugin-ember": "^7.7.2", 51 | "eslint-plugin-node": "^11.0.0", 52 | "loader.js": "^4.7.0", 53 | "qunit-dom": "^1.0.0" 54 | }, 55 | "engines": { 56 | "node": "10.* || >= 12" 57 | }, 58 | "ember": { 59 | "edition": "octane" 60 | }, 61 | "ember-addon": { 62 | "configPath": "tests/dummy/config" 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /testem.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | test_page: 'tests/index.html?hidepassed', 3 | disable_watching: true, 4 | launch_in_ci: [ 5 | 'Chrome' 6 | ], 7 | launch_in_dev: [ 8 | 'Chrome' 9 | ], 10 | browser_start_timeout: 120, 11 | browser_args: { 12 | Chrome: { 13 | ci: [ 14 | // --no-sandbox is needed when running Chrome inside a container 15 | process.env.CI ? '--no-sandbox' : null, 16 | '--headless', 17 | '--disable-dev-shm-usage', 18 | '--disable-software-rasterizer', 19 | '--mute-audio', 20 | '--remote-debugging-port=0', 21 | '--window-size=1440,900' 22 | ].filter(Boolean) 23 | } 24 | } 25 | }; 26 | -------------------------------------------------------------------------------- /tests/dummy/app/app.js: -------------------------------------------------------------------------------- 1 | import Application from '@ember/application'; 2 | import Resolver from 'ember-resolver'; 3 | import loadInitializers from 'ember-load-initializers'; 4 | import config from './config/environment'; 5 | 6 | export default class App extends Application { 7 | modulePrefix = config.modulePrefix; 8 | podModulePrefix = config.podModulePrefix; 9 | Resolver = Resolver; 10 | } 11 | 12 | loadInitializers(App, config.modulePrefix); 13 | -------------------------------------------------------------------------------- /tests/dummy/app/components/counter.js: -------------------------------------------------------------------------------- 1 | import Component from '@ember/component'; 2 | import layout from '../templates/components/counter'; 3 | import { action } from '@ember/object'; 4 | 5 | export default Component.extend({ 6 | layout, 7 | 8 | count: 0, 9 | onUpdate: null, 10 | 11 | updateCount: action(function() { 12 | this.incrementProperty('count'); 13 | 14 | if (this.onUpdate) { 15 | this.onUpdate(this.count); 16 | } 17 | }), 18 | }); 19 | -------------------------------------------------------------------------------- /tests/dummy/app/components/parent.js: -------------------------------------------------------------------------------- 1 | import Component from '@ember/component'; 2 | import layout from '../templates/components/parent'; 3 | 4 | export default Component.extend({ 5 | layout, 6 | }); 7 | -------------------------------------------------------------------------------- /tests/dummy/app/controllers/application.js: -------------------------------------------------------------------------------- 1 | import Controller from '@ember/controller'; 2 | import User from 'dummy/models/user'; 3 | 4 | export default Controller.extend({ 5 | init() { 6 | this._super(...arguments); 7 | this.set('user', User.create({ name: 'Alice' })) 8 | } 9 | }) -------------------------------------------------------------------------------- /tests/dummy/app/helpers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzuraq/ember-simple-set-helper/af636c8406a6626c0580d04fa3d914ea88ba9a42/tests/dummy/app/helpers/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Dummy 7 | 8 | 9 | 10 | {{content-for "head"}} 11 | 12 | 13 | 14 | 15 | {{content-for "head-footer"}} 16 | 17 | 18 | {{content-for "body"}} 19 | 20 | 21 | 22 | 23 | {{content-for "body-footer"}} 24 | 25 | 26 | -------------------------------------------------------------------------------- /tests/dummy/app/models/user.js: -------------------------------------------------------------------------------- 1 | import EmberObject from '@ember/object'; 2 | 3 | export default EmberObject.extend({ 4 | name: '' 5 | }) -------------------------------------------------------------------------------- /tests/dummy/app/router.js: -------------------------------------------------------------------------------- 1 | import EmberRouter from '@ember/routing/router'; 2 | import config from './config/environment'; 3 | 4 | export default class Router extends EmberRouter { 5 | location = config.locationType; 6 | rootURL = config.rootURL; 7 | } 8 | 9 | Router.map(function() { 10 | }); 11 | -------------------------------------------------------------------------------- /tests/dummy/app/routes/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzuraq/ember-simple-set-helper/af636c8406a6626c0580d04fa3d914ea88ba9a42/tests/dummy/app/routes/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/styles/app.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzuraq/ember-simple-set-helper/af636c8406a6626c0580d04fa3d914ea88ba9a42/tests/dummy/app/styles/app.css -------------------------------------------------------------------------------- /tests/dummy/app/templates/application.hbs: -------------------------------------------------------------------------------- 1 |
2 | {{this.greeting}} 3 |
4 | 5 |
6 | 9 |
10 | 11 |
12 | 13 |
14 | count: {{this.count}} 15 |
16 |
17 | 18 |
19 | 20 |
21 | 22 |
23 |

Name: {{this.user.name}}

24 | 25 |
26 | -------------------------------------------------------------------------------- /tests/dummy/app/templates/components/child.hbs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dummy/app/templates/components/counter.hbs: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /tests/dummy/app/templates/components/parent.hbs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /tests/dummy/config/environment.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function(environment) { 4 | let ENV = { 5 | modulePrefix: 'dummy', 6 | environment, 7 | rootURL: '/', 8 | locationType: 'auto', 9 | EmberENV: { 10 | FEATURES: { 11 | // Here you can enable experimental features on an ember canary build 12 | // e.g. EMBER_NATIVE_DECORATOR_SUPPORT: true 13 | }, 14 | EXTEND_PROTOTYPES: { 15 | // Prevent Ember Data from overriding Date.parse. 16 | Date: false 17 | } 18 | }, 19 | 20 | APP: { 21 | // Here you can pass flags/options to your application instance 22 | // when it is created 23 | } 24 | }; 25 | 26 | if (environment === 'development') { 27 | // ENV.APP.LOG_RESOLVER = true; 28 | // ENV.APP.LOG_ACTIVE_GENERATION = true; 29 | // ENV.APP.LOG_TRANSITIONS = true; 30 | // ENV.APP.LOG_TRANSITIONS_INTERNAL = true; 31 | // ENV.APP.LOG_VIEW_LOOKUPS = true; 32 | } 33 | 34 | if (environment === 'test') { 35 | // Testem prefers this... 36 | ENV.locationType = 'none'; 37 | 38 | // keep test console output quieter 39 | ENV.APP.LOG_ACTIVE_GENERATION = false; 40 | ENV.APP.LOG_VIEW_LOOKUPS = false; 41 | 42 | ENV.APP.rootElement = '#ember-testing'; 43 | ENV.APP.autoboot = false; 44 | } 45 | 46 | if (environment === 'production') { 47 | // here you can enable a production-specific feature 48 | } 49 | 50 | return ENV; 51 | }; 52 | -------------------------------------------------------------------------------- /tests/dummy/config/optional-features.json: -------------------------------------------------------------------------------- 1 | { 2 | "application-template-wrapper": false, 3 | "default-async-observers": true, 4 | "jquery-integration": false, 5 | "template-only-glimmer-components": true 6 | } 7 | -------------------------------------------------------------------------------- /tests/dummy/config/targets.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const browsers = [ 4 | 'last 1 Chrome versions', 5 | 'last 1 Firefox versions', 6 | 'last 1 Safari versions' 7 | ]; 8 | 9 | const isCI = !!process.env.CI; 10 | const isProduction = process.env.EMBER_ENV === 'production'; 11 | 12 | if (isCI || isProduction) { 13 | browsers.push('ie 11'); 14 | } 15 | 16 | module.exports = { 17 | browsers 18 | }; 19 | -------------------------------------------------------------------------------- /tests/dummy/public/robots.txt: -------------------------------------------------------------------------------- 1 | # http://www.robotstxt.org 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /tests/helpers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzuraq/ember-simple-set-helper/af636c8406a6626c0580d04fa3d914ea88ba9a42/tests/helpers/.gitkeep -------------------------------------------------------------------------------- /tests/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Dummy Tests 7 | 8 | 9 | 10 | {{content-for "head"}} 11 | {{content-for "test-head"}} 12 | 13 | 14 | 15 | 16 | 17 | {{content-for "head-footer"}} 18 | {{content-for "test-head-footer"}} 19 | 20 | 21 | {{content-for "body"}} 22 | {{content-for "test-body"}} 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | {{content-for "body-footer"}} 31 | {{content-for "test-body-footer"}} 32 | 33 | 34 | -------------------------------------------------------------------------------- /tests/integration/helpers/set-test.js: -------------------------------------------------------------------------------- 1 | import { module, test } from 'qunit'; 2 | import { setupRenderingTest } from 'ember-qunit'; 3 | import { render, find, click } from '@ember/test-helpers'; 4 | import hbs from 'htmlbars-inline-precompile'; 5 | import User from 'dummy/models/user'; 6 | 7 | module('Integration | Helper | set', function(hooks) { 8 | setupRenderingTest(hooks); 9 | 10 | test('it works', async function(assert) { 11 | await render(hbs` 12 | {{this.greeting}} 13 | 14 | 17 | `); 18 | 19 | assert.equal(find('[data-test-greeting]').textContent.trim(), ''); 20 | 21 | await click('button'); 22 | 23 | assert.equal(find('[data-test-greeting]').textContent.trim(), 'Hello!'); 24 | }); 25 | 26 | test('it works without a value', async function(assert) { 27 | await render(hbs` 28 | {{this.count}} 29 | 30 | `); 31 | 32 | assert.equal(find('[data-test-count]').textContent.trim(), ''); 33 | 34 | await click('button'); 35 | await click('button'); 36 | 37 | assert.equal(find('[data-test-count]').textContent.trim(), '2'); 38 | }); 39 | 40 | test('it works without a value on an object', async function(assert) { 41 | this.set('user', User.create({ name: 'Alice' })); 42 | await render(hbs` 43 | {{this.user.name}} 44 | 45 | `); 46 | 47 | assert.dom('[data-test-name]').hasText('Alice'); 48 | 49 | await click('button'); 50 | 51 | assert.dom('[data-test-name]').hasText('Bob'); 52 | }); 53 | }); 54 | -------------------------------------------------------------------------------- /tests/test-helper.js: -------------------------------------------------------------------------------- 1 | import Application from '../app'; 2 | import config from '../config/environment'; 3 | import { setApplication } from '@ember/test-helpers'; 4 | import { start } from 'ember-qunit'; 5 | 6 | setApplication(Application.create(config.APP)); 7 | 8 | start(); 9 | -------------------------------------------------------------------------------- /tests/unit/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzuraq/ember-simple-set-helper/af636c8406a6626c0580d04fa3d914ea88ba9a42/tests/unit/.gitkeep -------------------------------------------------------------------------------- /vendor/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzuraq/ember-simple-set-helper/af636c8406a6626c0580d04fa3d914ea88ba9a42/vendor/.gitkeep --------------------------------------------------------------------------------