-
Notifications
You must be signed in to change notification settings - Fork 190
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
added TextAreaValueChangeList #254
added TextAreaValueChangeList #254
Conversation
let textNode = dom.createTextNode(normalizedValue); | ||
textArea.appendChild(textNode); | ||
} else { | ||
let currentValue = textArea.value; |
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.
Can this section be safely moved to the updateAttribute
method?
Something like:
export const TextAreaValueChangeList = {
setAttribute(dom: DOMHelper, element: Element, attr: string, value: Opaque) {
let textArea = <HTMLTextAreaElement>element;
let normalizedValue = normalizeTextValue(value);
let textNode = dom.createTextNode(normalizedValue);
textArea.appendChild(textNode);
},
updateAttribute(dom: DOMHelper, element: Element, attr: string, value: Opaque) {
let textArea = <HTMLTextAreaElement>element;
let currentValue = textArea.value;
if (currentValue !== normalizedValue) {
textArea.value = normalizedValue;
}
}
};
Are there cases that ^ wouldn't work for?
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.
It depends on how we want this to render when someValue
is hello
?
<textarea value={{someValue}}>why would someone put text here too?</textarea>
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 just checked, with your proposed change the initial render would be:
<textarea>why would someone put text here too?hello</textarea>
then on updating someValue
to "goodbye":
<textarea>goodbye</textarea>
It seems to be most consistent to ensure that the property value is used. The current PR has an initial render of:
<textarea>hello</textarea>
and after update:
<textarea>goodbye</textarea>
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, technically <textarea>
doesn't have an attribute for value
. So actually having <textarea value={{someThing}}></textarea>
seems wrong?
I was under the impression that writing a manual text area would look like:
<textarea>{{someValue}}</textarea>
Though I guess this also has issues, because now updates won't work properly?
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.
It's a good point, the initial issue was to do with {{textarea value=foo}}
where foo=''
, not <textarea value={{foo}} />
.
Somewhere along the line I changed it to <textarea>
, probably when trying to get a failing test in glimmer.
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've added a failing test in ember for the {{textarea value=someEmptyString}}
case: emberjs/ember.js#14021
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've modified TextAreaValueChangeList
as you suggested
@krisselden r+ in slack |
Following up on #250 (comment)
/cc @chancancode