Skip to content

Commit 44ac31d

Browse files
author
Edward Drapkin
committed
get rid of some IE9+ features
1 parent 3e737d2 commit 44ac31d

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

src/makeConfiguration.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default (userConfiguration = {}) => {
1515
errorWhenNotFound: true
1616
};
1717

18-
Object.keys(userConfiguration).forEach(name => {
18+
for(const name in userConfiguration) {
1919
const value = userConfiguration[name];
2020

2121
if (!(name in configuration)) {
@@ -27,7 +27,7 @@ export default (userConfiguration = {}) => {
2727
}
2828

2929
configuration[name] = value;
30-
});
30+
}
3131

3232
return configuration;
3333
};

src/parseStyleName.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
const styleNameIndex = {};
2+
import {trim, filterForTruthy} from './utils';
23

34
export default (styleNamePropertyValue: string, allowMultiple: boolean): Array<string> => {
45
let styleNames;
56

67
if (styleNameIndex[styleNamePropertyValue]) {
78
styleNames = styleNameIndex[styleNamePropertyValue];
89
} else {
9-
styleNames = styleNamePropertyValue.trim().split(' ').filter(e => !!e);
10+
styleNames = filterForTruthy(trim(styleNamePropertyValue).split(' '));
1011

1112
styleNameIndex[styleNamePropertyValue] = styleNames;
1213
}

src/utils.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,19 @@ export function isFunction(func) {
1111

1212
export function isArray(arr) {
1313
return Array.isArray ? Array.isArray(arr) : Object.prototype.toString.call(arr) === '[object Array]';
14-
}
14+
}
15+
16+
export function trim(str) {
17+
return String.prototype.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
18+
}
19+
20+
export function filterForTruthy(arr) {
21+
const results = [];
22+
for(const key in arr) {
23+
if(arr[key]) {
24+
results.push(arr[key]);
25+
}
26+
}
27+
28+
return results;
29+
}

0 commit comments

Comments
 (0)