Skip to content

Conversation

@helloRupa
Copy link
Contributor

… to match button on textContent

To add padding around the button text, I had to place them in spans. For the PausePlayToggle function to continue working, I had to update it to match the buttons based on textContent rather than innerHTML.


//for pause play
function PausePlayToggle(elem, id) {
if (elem.textContent == 'Pause') {
Copy link
Owner

Choose a reason for hiding this comment

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

what's the benefit of using '.textContent' instead of '.innerHTML' here.

Copy link
Contributor Author

@helloRupa helloRupa Oct 30, 2019

Choose a reason for hiding this comment

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

The buttons (Play/Pause, Restart, Remove) have no padding between the icon images and the text. In order to add padding between the icon and the text on those buttons, I had to place spans around the text.

When placing spans around the Play/Pause text, it breaks the PausePlayToggle function because that function updates the functionality of the button based on the text content of the button. Originally that function matched based on the innerHTML. However, the innerHTML of that button then becomes "<span...>Play", which doesn't match 'Play'.

Matching on innerHTML means that adding the inner spans for padding causes the Play/Pause button to stop working since the function can no longer find it in the DOM. By matching based on text content instead, the function does not break and is also more scalable. You can update the HTML of the button and it will still work provided the text content remains 'Play' or 'Pause'.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please let me know if I'm not making sense in my explanation. It's kind of a weird thing to describe. Also, in this PR, the padding I added between the text and icons in the buttons is really small (2px), which is maybe why it wasn't so noticeable.

@1995YogeshSharma
Copy link
Owner

what's the benefit of this change?
Visually, I see no difference in previous UI and this.

@1995YogeshSharma
Copy link
Owner

1995YogeshSharma commented Oct 29, 2019

Sorry, labelling the PR as 'draft' meanwhile.
(I'll remove the label once you explain the point in previous comment)

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.

2 participants