Skip to content

fix(ie11): replace Object.assign and Array.from. #15

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
},
"dependencies": {
"aphrodite": "^1.2.4",
"array-from": "^2.1.1",
Copy link
Collaborator

Choose a reason for hiding this comment

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

This module polyfills the environment, so we must not use it.

"babel-register": "^6.26.0",
"clean-css": "^4.1.9",
"global-cache": "^1.2.1",
Expand Down
3 changes: 2 additions & 1 deletion packages/compiler/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { JSDOM } from 'jsdom';
import values from 'object.values';
import entries from 'object.entries';
import globalCache from 'global-cache';
import arrayFrom from 'array-from';
import { StyleSheetServer, StyleSheet, css as compile } from 'aphrodite/no-important';

import CSSInterface from 'react-with-styles-interface-css';
Expand Down Expand Up @@ -38,7 +39,7 @@ function getCSS(stylesObject) {
entries(stylesObject).forEach(([styleName, styleDef]) => {
for (let i = 1; i <= maxSpecificity; i += 1) {
const repeatedSpecifier =
Array.from({ length: i }, () => `${styleName}_${i}`).join('.');
arrayFrom({ length: i }, () => `${styleName}_${i}`).join('.');
stylesObjectWithSpecificity[repeatedSpecifier] = styleDef;
}
});
Expand Down
3 changes: 2 additions & 1 deletion packages/interface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"dependencies": {
"aphrodite": "^1.2.5",
"array.prototype.flatten": "^1.2.1",
"global-cache": "^1.2.1"
"global-cache": "^1.2.1",
"object-assign": "^4.1.1"
Copy link
Collaborator

@ljharb ljharb Mar 16, 2018

Choose a reason for hiding this comment

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

First, please use object.assign, not the hyphen one - but second, this can be done with a babel transform (see react-dates for an example) and then it will also work for object spreads.

},
"peerDependencies": {
"react-with-styles": "^3.0.0"
Expand Down
4 changes: 3 additions & 1 deletion packages/interface/src/utils/separateStyles.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import assign from 'object-assign';

// This function takes an array of styles and separates them into styles that
// are handled by Aphrodite and inline styles.
function separateStyles(stylesArray) {
Expand All @@ -23,7 +25,7 @@ function separateStyles(stylesArray) {
if (typeof style === 'string') {
classNames.push(style);
} else {
Object.assign(inlineStyles, style);
assign(inlineStyles, style);
hasInlineStyles = true;
}
}
Expand Down