-
Notifications
You must be signed in to change notification settings - Fork 23
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
fix: Revert DOM clean up methods #160
Conversation
Given this JSBin: https://jsbin.com/?html,console,output When we serialize the CSSOM into the `<style>` tag that the in-memory styles own and then _remove_ those styles, it triggers `deleteRule` on those styles in the CSSOM. Which means we're removing the text we injected AND all of the styles that live in memory. This breaks their app. With the input cleaning, when we remove the value or checked attribute on the element, it's possible those elements lose their values entirely. For example, when we remove the `checked` attribute from checkboxes in the customers DOM, this will make the checkbox _no longer checked_, which is changing the state of their application. It would be better, in this world without an AST, to leave the mutations in place. Removing the mutations causes more issues than it tries to solve.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Might want to wait on @djones to review too
expect(domSnapshot).to.contain('.box { height: 500px; width: 500px; background-color: green; }') | ||
|
||
// we want to ensure mutiple snapshots are successful | ||
const secondDomSnapshot = await snapshot(page, 'Serialize CSSOM twice') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🍍 LGTM
## [0.3.1](v0.3.0...v0.3.1) (2019-04-18) ### Bug Fixes * Revert DOM clean up methods ([#160](#160)) ([12ab332](12ab332))
Why?
Given this JSBin: https://jsbin.com/?html,console,output
When we serialize the CSSOM into the
<style>
tag that the in-memory styles own and then remove those styles, it triggersdeleteRule
on those styles in the CSSOM. Which means we're removing the text we injected AND all of the styles that live in memory. This breaks their app.With the input cleaning, when we remove the value or checked attribute on the element, it's possible those elements lose their values entirely. For example, when we remove the
checked
attribute from checkboxes in the customers DOM, this will make the checkbox no longer checked, which is changing the state of their application. It would be better, in this world without an AST, to leave the mutations in place. Removing the mutations causes more issues than it tries to solve.Future solve
I think we should really explore transforming their DOM into an AST and modifying it after we've
POST
'ed it to the agent process. This would 100% ensure we're not mutating the customers DOM in any way. This is not a simple change, but I believe it is the right change.TODO