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

Switch to use Web API in Slidedown and Tagging Container #681

Merged
merged 8 commits into from
Aug 17, 2020

Conversation

rgomezp
Copy link
Contributor

@rgomezp rgomezp commented Jul 29, 2020

Description

This change includes a transition from using hard-coded HTML strings to using the W3C Web API to create DOM elements programmatically. The main reason for this is for security purposes since this approach is an easy way to avoid injection vulnerabilities.

This PR also includes other tweaks like the addition of CSS and Element ID constants, 1 file rename, and other minor nits.

Systems Affected

WebSDK only

Validation

Tests

  • All the automated tests pass or I explained why that is not possible
  • I have personally tested this on my machine or explained why that is not possible
  • I have included test coverage for these changes or explained why they are not needed

Test coverage for these changes are not needed since the only change was a switch to how DOM elements are created.

Screenshots

  • I have included screenshots/recordings of the intended results or explained why they are not needed

Nothing has visually changed in this PR.


This change is Reviewable

@rgomezp rgomezp force-pushed the slidedown-web-api-switch branch 3 times, most recently from f2301f0 to 342adb7 Compare July 30, 2020 23:56
rgomezp added 5 commits July 31, 2020 14:53
New CSS class constants:
- 'slide-up'
- 'slide-down'
- close-slidedown'

Refactoring
- Switched to all caps constant typescript convention
After shifting from hard-coded HTML approach to Web API approach, the function returns a web Element so we are renaming it here to be more clear.
@rgomezp rgomezp force-pushed the slidedown-web-api-switch branch from 342adb7 to 1485574 Compare July 31, 2020 19:53
@rgomezp rgomezp marked this pull request as ready for review July 31, 2020 20:09
@rgomezp rgomezp requested a review from itrush July 31, 2020 20:09
@jkasten2 jkasten2 self-requested a review August 11, 2020 19:05
Copy link
Member

@jkasten2 jkasten2 left a comment

Choose a reason for hiding this comment

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

You noted you tested on this on your machine, can you explain in more detail what was tested to confirm we covered everything that could be effected?
Some things I recommend testing:

  1. Visually normal slidedown.
  2. Visually category slidedown.
  3. Saving categories saves correct values
  4. Visually category slidedown when updating.

TestEnvironment:
- Need to mock the Dom environment for tests to pass now that we are using the WebApi to create elements
TaggingContainer:
- switched to use `value` instead of `defaultValue` which is actually what we want
Previously, the span and indicator holder elements would not display the pointer as the cursor which was inconsistent with the parent Button element.
It's bad practice to set `innerHTML` as this has a high performance cost. 

Instead of using `innerHTML` we switch to use `textContent` when the only thing being replaced is the text. When we insert multiple children nodes to the element (button), we now use the helper functions `getIndicatorHolder` and `getTextSpan` to separately generate the HTML Elements needed to insert as a child element to the button by using `insertAdjacentElement`.
@rgomezp rgomezp force-pushed the slidedown-web-api-switch branch from 1485574 to 468243d Compare August 12, 2020 23:24
@rgomezp rgomezp requested a review from jkasten2 August 12, 2020 23:38
Copy link
Member

@jkasten2 jkasten2 left a comment

Choose a reason for hiding this comment

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

Changes all look good now, however please confirm what was tested before mering in
#681 (review)

@rgomezp
Copy link
Contributor Author

rgomezp commented Aug 13, 2020

  • Visually normal slidedown.
  • Visually category slidedown.
  • Saving categories saves correct values
  • Visually category slidedown when updating.

@rgomezp rgomezp merged commit afde89b into master Aug 17, 2020
@rgomezp rgomezp deleted the slidedown-web-api-switch branch August 17, 2020 22:59
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