Skip to content
This repository has been archived by the owner on Nov 3, 2020. It is now read-only.

shallow copies are evil. Copy the DOM node properly. #126

Merged
merged 1 commit into from
Sep 3, 2020

Conversation

benadida
Copy link
Contributor

@benadida benadida commented Sep 3, 2020

addresses #114.

Comment on lines +150 to +154
newLastPageElement.setAttribute(
'data-page-number',
`${pages.length + 1}`
)
newLastPageElement.setAttribute('data-id', `page-${pages.length + 1}`)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason not to use the approach we had, i.e.

Suggested change
newLastPageElement.setAttribute(
'data-page-number',
`${pages.length + 1}`
)
newLastPageElement.setAttribute('data-id', `page-${pages.length + 1}`)
newLastPageElement.dataset.pageNumber = `${pages.length + 1}`
newLastPageElement.dataset.id = `page-${pages.length + 1}`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe, but the approach we had was via setAttribute so I didn't want to change it. I added the id one cause it was missing.

Comment on lines +164 to +167
const newPage = {
...pages[pages.length - 1],
element: newLastPageElement,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the actual fix, right? Everything else should be equivalent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should, yes. Trying to change as little as possible.

@benadida benadida merged commit 903cf18 into main Sep 3, 2020
@benadida benadida deleted the fix-last-blank-page-qr-code branch September 3, 2020 22:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants