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

[core] Remove dom-helpers dependency #14877

Merged
merged 2 commits into from Mar 14, 2019

Conversation

oliviertassinari
Copy link
Member

@oliviertassinari oliviertassinari commented Mar 13, 2019

Save -4.92% gzipped on the Modal component.

@oliviertassinari oliviertassinari force-pushed the kill-dom-helpers branch 3 times, most recently from b25995e to 15c968f Compare March 13, 2019 22:29
const marginRight = parseInt(style.getPropertyValue('margin-right'), 10);

return marginLeft + doc.body.clientWidth + marginRight < win.innerWidth;
return container.scrollHeight > container.clientHeight;
Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -17,7 +17,8 @@ function findIndexOf(data, callback) {
}

function getPaddingRight(node) {
return parseInt(css(node, 'paddingRight') || 0, 10);
const win = ownerWindow(node);
return parseInt(win.getComputedStyle(node)['padding-right'] || 0, 10);
Copy link
Member Author

Choose a reason for hiding this comment

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

@mui-pr-bot
Copy link

mui-pr-bot commented Mar 13, 2019

@material-ui/core: parsed: -1.26% 😍, gzip: -1.46% 😍

Details of bundle changes.

Comparing: bdb4baa...09babf7

bundle parsed diff gzip diff prev parsed current parsed prev gzip current gzip
@material-ui/core -1.26% -1.46% 361,335 356,770 92,103 90,755
@material-ui/core/Paper -0.02% +0.01% 🔺 68,536 68,525 19,978 19,979
@material-ui/core/Paper.esm 0.00% 0.00% 61,725 61,725 18,888 18,888
@material-ui/core/Popper 0.00% +0.02% 🔺 30,458 30,458 10,567 10,569
@material-ui/core/styles/createMuiTheme 0.00% +0.05% 🔺 17,284 17,284 5,700 5,703
@material-ui/core/useMediaQuery 0.00% +0.29% 🔺 2,471 2,471 1,038 1,041
@material-ui/lab +0.02% 🔺 +0.01% 🔺 170,524 170,555 49,897 49,901
@material-ui/styles 0.00% -0.01% 53,729 53,729 15,486 15,485
@material-ui/system 0.00% +0.11% 🔺 17,041 17,041 4,488 4,493
Button -0.00% +0.01% 🔺 90,262 90,258 26,730 26,732
Modal -5.23% -4.93% 88,646 84,008 26,317 25,019
colorManipulator 0.00% -0.08% 3,232 3,232 1,298 1,297
docs.landing 0.00% 0.00% 51,976 51,976 11,324 11,324
docs.main -0.72% -0.80% 651,342 646,666 202,307 200,679
packages/material-ui/build/umd/material-ui.production.min.js -1.52% -1.68% 311,373 306,629 85,482 84,044

Generated by 🚫 dangerJS against 09babf7

@oliviertassinari
Copy link
Member Author

I will continue the effort tomorrow, I was interested in the gain potential. It's worth pushing.

@oliviertassinari
Copy link
Member Author

oliviertassinari commented Mar 14, 2019

The biggest win comes from:

-import css from 'dom-helpers/style';
-return parseInt(css(node, 'paddingRight') || 0, 10);
+return parseInt(win.getComputedStyle(node)['padding-right'] || 0, 10);

@oliviertassinari oliviertassinari force-pushed the kill-dom-helpers branch 2 times, most recently from 8380212 to e7a847d Compare March 14, 2019 10:22
@oliviertassinari oliviertassinari marked this pull request as ready for review March 14, 2019 10:23
packages/material-ui/src/Modal/Modal.test.js Outdated Show resolved Hide resolved
container1.style.padding = '20px';
Object.defineProperty(container1, 'scrollHeight', {
value: 100,
writable: false,
Copy link
Member

Choose a reason for hiding this comment

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

This will not really prevent writing. All it does is throw an error. I would rather sinon.stub this with a fake setter:

sinon.stub(container1, 'scrollHeight').get(() => 100).set(() => {})

writable: false will actually not trigger an error. Would've been nice if sinon would support this out of the box.

@@ -113,15 +122,22 @@ describe('ModalManager', () => {
it('should handle the scroll', () => {
const modal = {};
const paddingRightBefore = container1.style.paddingRight;
const paddingFixedRightBefore = fixedNode.style.paddingRight;
Copy link
Member

Choose a reason for hiding this comment

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

Is this just refactoring or did the test actually break?

Copy link
Member Author

Choose a reason for hiding this comment

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

Both.

Copy link
Member

Choose a reason for hiding this comment

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

So this is a breaking change after all or only breaking in jsdom?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that it's only breaking jsdom.

packages/material-ui/src/Tabs/ScrollbarSize.js Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants