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

✅ TEST: createElement instead of insertAdjacentHTML #23454

Merged
merged 1 commit into from Jul 23, 2019

Conversation

xrav3nz
Copy link
Contributor

@xrav3nz xrav3nz commented Jul 22, 2019

This change migrates the test to use the preferred createElement and
setAttribute to set up test elements.

Test elements for isFieldDefault were originally created with
insertAdjacentHTML to ensure their defaultValue(*) properties are
generated correctly. It turns out setAttribute actually modifies the
element's HTML definition, and thus could update the defaultValue
property.

* The defaultValue property returns "the default value as originally
specified in the HTML that created this object."
https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement#Properties

Follow-up for #22541 (comment), related to #22534.

/cc @GoTcWang, @cvializ thanks!

The `defaultValue` property returns "the default value as originally
specified in the HTML that created this object."
https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement#Properties

Test elements for `isFieldDefault` were originally created with
`insertAdjacentHTML` to ensure their `defaultValue` properties is
generated correctly. It turns out `setAttribute` actually modifies the
element's HTML definition, and thus could update the `defaultValue`
property.

This change migrates the test to use the preferred `createElement` and
`setAttribute` to set up test elements.
@GoTcWang
Copy link
Contributor

Code looks good, consider arrange the description in a way like:

"what we are changing":
This change migrates the test to use the preferred createElement and
setAttribute to set up test elements.

"why we are changing":
Test elements for isFieldDefault were originally created with
insertAdjacentHTML to ensure their defaultValue properties are
generated correctly. It turns out setAttribute actually modifies the
element's HTML definition, and thus could update the defaultValue
property.

"references":
The defaultValue property returns "the default value as originally
specified in the HTML that created this object."
https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement#Properties

Copy link
Contributor

@cvializ cvializ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, LGTM thanks for coming back and improving that!

@cvializ cvializ merged commit 7fc360d into ampproject:master Jul 23, 2019
@xrav3nz xrav3nz deleted the test/is-field-default branch July 23, 2019 21:47
rindo pushed a commit to logly/amphtml that referenced this pull request Jul 24, 2019
The `defaultValue` property returns "the default value as originally
specified in the HTML that created this object."
https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement#Properties

Test elements for `isFieldDefault` were originally created with
`insertAdjacentHTML` to ensure their `defaultValue` properties is
generated correctly. It turns out `setAttribute` actually modifies the
element's HTML definition, and thus could update the `defaultValue`
property.

This change migrates the test to use the preferred `createElement` and
`setAttribute` to set up test elements.
thekorn pushed a commit to edelight/amphtml that referenced this pull request Sep 11, 2019
The `defaultValue` property returns "the default value as originally
specified in the HTML that created this object."
https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement#Properties

Test elements for `isFieldDefault` were originally created with
`insertAdjacentHTML` to ensure their `defaultValue` properties is
generated correctly. It turns out `setAttribute` actually modifies the
element's HTML definition, and thus could update the `defaultValue`
property.

This change migrates the test to use the preferred `createElement` and
`setAttribute` to set up test elements.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants