-
Notifications
You must be signed in to change notification settings - Fork 52
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
Proposed fix for breakage in "Fix echo update" #52
Conversation
I should add a test that tests the ability to sanitize inputs set through the binding. |
Added a test, but unsure if test tests the right thing |
@@ -86,12 +86,16 @@ const OneWayInputComponent = Component.extend({ | |||
}, | |||
|
|||
init() { | |||
this._super(...arguments); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_super
should always happen before touching this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that with version 2.0
(and possibly 1.13
) the didReceiveAttrs
hook gets called during the _super
call. That would mean the _processNewValue
gets called before _sanitezedValue
has been set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that was fixed with emberjs/ember.js#12260 and was backported to 1.13.9 and 2.0.1. What version were you testing with?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2.0.3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
O_o
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seeing that reaction, I'll double check it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ember.VERSION === '2.0.3'
init() {
this._super(...arguments);
let value = get(this, 'paramValue') || get(this, 'value');
set(this, 'value', value);
debugger;
this._sanitizedValue = get(this, 'value') || get(this, 'checked');
},
didReceiveAttrs() {
debugger;
this._super(...arguments);
this._processNewValue.call(this, undefined, get(this, get(this, 'appropriateAttr')));
}
The debugger in didReceiveAttrs
gets hit first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I think you are correct: http://rwjblue.jsbin.com/vexodub/edit?html,js,output
This was listed as fixed in the CHANGELOG for 2.0.1 though, so I must have screwed something up 😞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, apparently I fail at computers for the day. I guess this is ok as long as you leave a comment explaining why (// @rwjblue sucks at releasing and 2.0.3 contains a dumb bug
)...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will for sure add that comment! 👍
The test added here looks good (and does test a previously untested scenario), but wasnt' quite the scenario that I was thinking of. I was thinking more along the lines of: test('It triggers sanitizeInput on value binding change', function(assert) {
this.on('sanitize', (value) => value && value.toUpperCase());
this.set('value', 'foo');
this.render(hbs`{{one-way-input value=value
sanitizeInput=(action 'sanitize')
update=(action (mut foo))}}`);
// initial render with an invalid value gets sanitized and calls update
assert.equal(this.get('value'), 'FOO');
this.set('value', 'bar');
// set triggered a rerender, which sanitized the input and called update
assert.equal(this.get('value'), 'BAR');
}); |
@homu r+ |
📌 Commit e1c199d has been approved by |
⚡ Test exempted - status |
Proposed fix for breakage in "Fix echo update" None
No description provided.