Skip to content
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

Closed
wants to merge 1 commit into from
Closed

added TextAreaValueChangeList #254

wants to merge 1 commit into from

Conversation

GavinJoyce
Copy link
Contributor

Following up on #250 (comment)

/cc @chancancode

let textNode = dom.createTextNode(normalizedValue);
textArea.appendChild(textNode);
} else {
let currentValue = textArea.value;
Copy link
Member

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?

Copy link
Contributor Author

@GavinJoyce GavinJoyce Aug 4, 2016

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>

Copy link
Contributor Author

@GavinJoyce GavinJoyce Aug 4, 2016

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>

Copy link
Member

@rwjblue rwjblue Aug 4, 2016

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

@GavinJoyce GavinJoyce Aug 8, 2016

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

@rwjblue
Copy link
Member

rwjblue commented Aug 18, 2016

@krisselden r+ in slack

screenshot

@GavinJoyce GavinJoyce closed this Jan 10, 2017
@GavinJoyce GavinJoyce deleted the gj/text-area-value-change-list branch January 10, 2017 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants