Skip to content

Commit d3a870f

Browse files
committed
fix: ie11-custom-properties
1 parent b5143bb commit d3a870f

File tree

10 files changed

+1476
-493
lines changed

10 files changed

+1476
-493
lines changed

.babelrc.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
module.exports = {
22
presets: [
33
[
4-
'@babel/env',
4+
'@babel/preset-env',
55
{
6+
'targets': {
7+
'browsers': [
8+
"> 1%",
9+
"IE 10"
10+
]
11+
},
612
loose: true,
713
modules: false,
814
exclude: ['transform-typeof-symbol']
@@ -11,7 +17,10 @@ module.exports = {
1117
],
1218
plugins: [
1319
process.env.PLUGINS && 'transform-es2015-modules-strip',
14-
['@babel/proposal-object-rest-spread', {loose: true, useBuiltIns: true}],
20+
['@babel/proposal-object-rest-spread', {
21+
loose: true,
22+
useBuiltIns: true
23+
}],
1524
'@babel/plugin-proposal-throw-expressions'
1625
].filter(Boolean),
1726
env: {

dist/js/coreui.js

Lines changed: 29 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/coreui.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/coreui.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/coreui.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/dist/utilities/get-style.js

Lines changed: 29 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/dist/utilities/get-style.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/src/utilities/get-style.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@
55
* --------------------------------------------------------------------------
66
*/
77

8+
/* eslint-disable */
89
const getCssCustomProperties = () => {
910
const cssCustomProperties = {}
1011
const stylesheets = new Map(Object.entries(document.styleSheets))
1112
stylesheets.forEach((stylesheet) => {
13+
console.log(property)
1214
const rules = new Map(Object.entries(stylesheet.cssRules))
1315
rules.forEach((rule) => {
1416
if (rule.selectorText === '.ie-custom-properties') {
1517
rule.style.cssText.split('; ').forEach((property) => {
18+
console.log(property)
1619
const name = property.split(': ')[0]
1720
const value = property.split(': ')[1]
1821
cssCustomProperties[`--${name}`] = value
@@ -27,12 +30,32 @@ const isIE11 = () => Boolean(window.MSInputMethodContext) && Boolean(document.do
2730
const isCustomProperty = (property) => property.match(/^--.*/i)
2831

2932
const getStyle = (property, element = document.body) => {
30-
if (isCustomProperty(property) && isIE11) {
33+
let style
34+
if (isCustomProperty(property) && isIE11()) {
3135
const cssCustomProperties = getCssCustomProperties()
32-
return cssCustomProperties[property]
36+
style = cssCustomProperties[property]
37+
// console.log(cssCustomProperties)
3338
} else {
34-
return window.getComputedStyle(element, null).getPropertyValue(property).replace(/^\s/, '')
39+
style = window.getComputedStyle(element, null).getPropertyValue(property).replace(/^\s/, '')
3540
}
41+
// eslint-disable-next-line no-console
42+
// console.log(isIE11())
43+
// eslint-disable-next-line no-console
44+
// console.log(property)
45+
// eslint-disable-next-line no-console
46+
// console.log(isCustomProperty(property))
47+
return style
3648
}
3749

50+
if (!Object.entries)
51+
Object.entries = function(obj){
52+
var ownProps = Object.keys(obj),
53+
i = ownProps.length,
54+
resArray = new Array(i); // preallocate the Array
55+
while (i--)
56+
resArray[i] = [ownProps[i], obj[ownProps[i]]]
57+
58+
return resArray
59+
};
60+
3861
export default getStyle

0 commit comments

Comments
 (0)