Last active
March 22, 2017 04:09
-
-
Save amk221/a8022eac7bbe8eb52801 to your computer and use it in GitHub Desktop.
Component helper didUpdateAttrs bug
This file contains hidden or 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
| import Ember from 'ember'; | |
| export default Ember.Controller.extend({ | |
| value: 1, | |
| actions: { | |
| changeValue() { | |
| this.incrementProperty('value') | |
| } | |
| } | |
| }); |
This file contains hidden or 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
| import Ember from 'ember'; | |
| export default Ember.Component.extend({ | |
| classNames: ['my-component'], | |
| didReceiveAttrs() { | |
| console.log('my-component didReceiveAttrs with value', this.getAttr('my-attr')); | |
| } | |
| }); |
This file contains hidden or 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
| import Ember from 'ember'; | |
| export default Ember.Component.extend({ | |
| classNames: ['my-nested-component'], | |
| didReceiveAttrs() { | |
| Ember.run.scheduleOnce('afterRender', this, () => { | |
| console.log( | |
| 'my-nested-component didReceiveAttrs with value', | |
| this.getAttr('my-parent-attr') + ',', | |
| 'expecting', | |
| this.$().html().match(/\d+/)[0] | |
| ); | |
| console.log('--'); | |
| }); | |
| // This isn't working as I'd expect | |
| this.set('myProp', this.getAttr('my-parent-attr')); | |
| } | |
| }); |
This file contains hidden or 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
| body { | |
| margin: 15px; | |
| font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
| font-size: 12px; | |
| color: gray | |
| } | |
| .my-component { | |
| border: 1px solid red; | |
| margin: 15px; | |
| padding: 10px; | |
| position: relative; | |
| } | |
| .my-component::before { | |
| content: '{{my-component my-attr=value}}'; | |
| font-family: monospace; | |
| position: absolute; | |
| color: red; | |
| top: -1.5em; | |
| left: 0; | |
| } | |
| .my-nested-component { | |
| border: 1px solid blue; | |
| margin: 30px 10px 10px; | |
| padding: 10px; | |
| position: relative; | |
| } | |
| .my-nested-component::before { | |
| content: '{{my-nested-component my-parent-attr=attrs.my-attr}}'; | |
| font-family: monospace; | |
| position: absolute; | |
| color: blue; | |
| top: -1.5em; | |
| left: 0; | |
| } |
This file contains hidden or 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
| { | |
| "version": "0.4.16", | |
| "EmberENV": { | |
| "FEATURES": {} | |
| }, | |
| "dependencies": { | |
| "jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
| "ember": "canary", | |
| "ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.1.0/ember-data.js", | |
| "ember-template-compiler": "canary" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment