feat(omi): cach css style sheet
This commit is contained in:
parent
4ebfe11df4
commit
e4dfed24ea
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Omi v6.22.2 http://omijs.org
|
||||
* Omi v6.23.0 http://omijs.org
|
||||
* Front End Cross-Frameworks Framework.
|
||||
* By dntzhang https://github.com/dntzhang
|
||||
* Github: https://github.com/Tencent/omi
|
||||
|
@ -797,26 +797,31 @@
|
|||
}
|
||||
}
|
||||
|
||||
var css = this.constructor.css;
|
||||
if (css) {
|
||||
if (typeof css === 'string') {
|
||||
var styleSheet = new CSSStyleSheet();
|
||||
styleSheet.replaceSync(css);
|
||||
shadowRoot.adoptedStyleSheets = [styleSheet];
|
||||
} else if (Object.prototype.toString.call(css) === '[object Array]') {
|
||||
var styleSheets = [];
|
||||
css.forEach(function (styleSheet) {
|
||||
if (typeof styleSheet === 'string') {
|
||||
var adoptedStyleSheet = new CSSStyleSheet();
|
||||
adoptedStyleSheet.replaceSync(styleSheet);
|
||||
styleSheets.push(adoptedStyleSheet);
|
||||
} else {
|
||||
styleSheets.push(styleSheet);
|
||||
}
|
||||
shadowRoot.adoptedStyleSheets = styleSheets;
|
||||
});
|
||||
} else {
|
||||
shadowRoot.adoptedStyleSheets = [css];
|
||||
if (this.constructor.elementStyles) {
|
||||
shadowRoot.adoptedStyleSheets = this.constructor.elementStyles;
|
||||
} else {
|
||||
var css = this.constructor.css;
|
||||
if (css) {
|
||||
if (typeof css === 'string') {
|
||||
var styleSheet = new CSSStyleSheet();
|
||||
styleSheet.replaceSync(css);
|
||||
shadowRoot.adoptedStyleSheets = [styleSheet];
|
||||
} else if (Object.prototype.toString.call(css) === '[object Array]') {
|
||||
var styleSheets = [];
|
||||
css.forEach(function (styleSheet) {
|
||||
if (typeof styleSheet === 'string') {
|
||||
var adoptedStyleSheet = new CSSStyleSheet();
|
||||
adoptedStyleSheet.replaceSync(styleSheet);
|
||||
styleSheets.push(adoptedStyleSheet);
|
||||
} else {
|
||||
styleSheets.push(styleSheet);
|
||||
}
|
||||
shadowRoot.adoptedStyleSheets = styleSheets;
|
||||
});
|
||||
} else {
|
||||
shadowRoot.adoptedStyleSheets = [css];
|
||||
}
|
||||
this.constructor.elementStyles = shadowRoot.adoptedStyleSheets;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1549,7 +1554,7 @@
|
|||
|
||||
options.root.Omi = omi;
|
||||
options.root.omi = omi;
|
||||
options.root.Omi.version = '6.22.2';
|
||||
options.root.Omi.version = '6.23.0';
|
||||
|
||||
if (typeof module != 'undefined') module.exports = omi;else self.Omi = omi;
|
||||
}());
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Omi v6.22.2 http://omijs.org
|
||||
* Omi v6.23.0 http://omijs.org
|
||||
* Front End Cross-Frameworks Framework.
|
||||
* By dntzhang https://github.com/dntzhang
|
||||
* Github: https://github.com/Tencent/omi
|
||||
|
@ -794,26 +794,31 @@ var WeElement = function (_HTMLElement) {
|
|||
}
|
||||
}
|
||||
|
||||
var css = this.constructor.css;
|
||||
if (css) {
|
||||
if (typeof css === 'string') {
|
||||
var styleSheet = new CSSStyleSheet();
|
||||
styleSheet.replaceSync(css);
|
||||
shadowRoot.adoptedStyleSheets = [styleSheet];
|
||||
} else if (Object.prototype.toString.call(css) === '[object Array]') {
|
||||
var styleSheets = [];
|
||||
css.forEach(function (styleSheet) {
|
||||
if (typeof styleSheet === 'string') {
|
||||
var adoptedStyleSheet = new CSSStyleSheet();
|
||||
adoptedStyleSheet.replaceSync(styleSheet);
|
||||
styleSheets.push(adoptedStyleSheet);
|
||||
} else {
|
||||
styleSheets.push(styleSheet);
|
||||
}
|
||||
shadowRoot.adoptedStyleSheets = styleSheets;
|
||||
});
|
||||
} else {
|
||||
shadowRoot.adoptedStyleSheets = [css];
|
||||
if (this.constructor.elementStyles) {
|
||||
shadowRoot.adoptedStyleSheets = this.constructor.elementStyles;
|
||||
} else {
|
||||
var css = this.constructor.css;
|
||||
if (css) {
|
||||
if (typeof css === 'string') {
|
||||
var styleSheet = new CSSStyleSheet();
|
||||
styleSheet.replaceSync(css);
|
||||
shadowRoot.adoptedStyleSheets = [styleSheet];
|
||||
} else if (Object.prototype.toString.call(css) === '[object Array]') {
|
||||
var styleSheets = [];
|
||||
css.forEach(function (styleSheet) {
|
||||
if (typeof styleSheet === 'string') {
|
||||
var adoptedStyleSheet = new CSSStyleSheet();
|
||||
adoptedStyleSheet.replaceSync(styleSheet);
|
||||
styleSheets.push(adoptedStyleSheet);
|
||||
} else {
|
||||
styleSheets.push(styleSheet);
|
||||
}
|
||||
shadowRoot.adoptedStyleSheets = styleSheets;
|
||||
});
|
||||
} else {
|
||||
shadowRoot.adoptedStyleSheets = [css];
|
||||
}
|
||||
this.constructor.elementStyles = shadowRoot.adoptedStyleSheets;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1546,7 +1551,7 @@ var omi = {
|
|||
|
||||
options.root.Omi = omi;
|
||||
options.root.omi = omi;
|
||||
options.root.Omi.version = '6.22.2';
|
||||
options.root.Omi.version = '6.23.0';
|
||||
|
||||
export default omi;
|
||||
export { tag, WeElement, Component, render, h, h as createElement, options, define, cloneElement, getHost, rpx, defineElement, classNames, extractClass, createRef, o, elements, $, extend$1 as extend, get, set, bind, unbind };
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -490,22 +490,27 @@
|
|||
var fc;
|
||||
while (fc = shadowRoot.firstChild) shadowRoot.removeChild(fc);
|
||||
}
|
||||
var css = this.constructor.css;
|
||||
if (css) if ('string' == typeof css) {
|
||||
var styleSheet = new CSSStyleSheet();
|
||||
styleSheet.replaceSync(css);
|
||||
shadowRoot.adoptedStyleSheets = [ styleSheet ];
|
||||
} else if ('[object Array]' === Object.prototype.toString.call(css)) {
|
||||
var styleSheets = [];
|
||||
css.forEach(function(styleSheet) {
|
||||
if ('string' == typeof styleSheet) {
|
||||
var adoptedStyleSheet = new CSSStyleSheet();
|
||||
adoptedStyleSheet.replaceSync(styleSheet);
|
||||
styleSheets.push(adoptedStyleSheet);
|
||||
} else styleSheets.push(styleSheet);
|
||||
shadowRoot.adoptedStyleSheets = styleSheets;
|
||||
});
|
||||
} else shadowRoot.adoptedStyleSheets = [ css ];
|
||||
if (this.constructor.elementStyles) shadowRoot.adoptedStyleSheets = this.constructor.elementStyles; else {
|
||||
var css = this.constructor.css;
|
||||
if (css) {
|
||||
if ('string' == typeof css) {
|
||||
var styleSheet = new CSSStyleSheet();
|
||||
styleSheet.replaceSync(css);
|
||||
shadowRoot.adoptedStyleSheets = [ styleSheet ];
|
||||
} else if ('[object Array]' === Object.prototype.toString.call(css)) {
|
||||
var styleSheets = [];
|
||||
css.forEach(function(styleSheet) {
|
||||
if ('string' == typeof styleSheet) {
|
||||
var adoptedStyleSheet = new CSSStyleSheet();
|
||||
adoptedStyleSheet.replaceSync(styleSheet);
|
||||
styleSheets.push(adoptedStyleSheet);
|
||||
} else styleSheets.push(styleSheet);
|
||||
shadowRoot.adoptedStyleSheets = styleSheets;
|
||||
});
|
||||
} else shadowRoot.adoptedStyleSheets = [ css ];
|
||||
this.constructor.elementStyles = shadowRoot.adoptedStyleSheets;
|
||||
}
|
||||
}
|
||||
this.beforeRender();
|
||||
options.afterInstall && options.afterInstall(this);
|
||||
var rendered = this.render(this.props, this.store);
|
||||
|
@ -924,7 +929,7 @@
|
|||
};
|
||||
options.root.Omi = omi;
|
||||
options.root.omi = omi;
|
||||
options.root.Omi.version = '6.22.2';
|
||||
options.root.Omi.version = '6.23.0';
|
||||
if ('undefined' != typeof module) module.exports = omi; else self.Omi = omi;
|
||||
}();
|
||||
//# sourceMappingURL=omi.js.map
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -8,4 +8,4 @@
|
|||
<my-counter count="4"></my-counter>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "omi",
|
||||
"version": "6.22.2",
|
||||
"version": "6.23.0",
|
||||
"description": "Front End Cross-Frameworks Framework.",
|
||||
"main": "dist/omi.js",
|
||||
"jsnext:main": "dist/omi.esm.js",
|
||||
|
|
|
@ -52,7 +52,7 @@ const omi = {
|
|||
|
||||
options.root.Omi = omi
|
||||
options.root.omi = omi
|
||||
options.root.Omi.version = '6.22.2'
|
||||
options.root.Omi.version = '6.23.0'
|
||||
|
||||
export default omi
|
||||
|
||||
|
|
|
@ -63,26 +63,31 @@ export default class WeElement extends HTMLElement {
|
|||
}
|
||||
}
|
||||
|
||||
const css = this.constructor.css
|
||||
if (css) {
|
||||
if (typeof css === 'string') {
|
||||
const styleSheet = new CSSStyleSheet()
|
||||
styleSheet.replaceSync(css)
|
||||
shadowRoot.adoptedStyleSheets = [styleSheet]
|
||||
} else if (Object.prototype.toString.call(css) === '[object Array]') {
|
||||
const styleSheets = []
|
||||
css.forEach(styleSheet => {
|
||||
if (typeof styleSheet === 'string') {
|
||||
const adoptedStyleSheet = new CSSStyleSheet()
|
||||
adoptedStyleSheet.replaceSync(styleSheet)
|
||||
styleSheets.push(adoptedStyleSheet)
|
||||
} else {
|
||||
styleSheets.push(styleSheet)
|
||||
}
|
||||
shadowRoot.adoptedStyleSheets = styleSheets
|
||||
})
|
||||
} else {
|
||||
shadowRoot.adoptedStyleSheets = [css]
|
||||
if (this.constructor.elementStyles) {
|
||||
shadowRoot.adoptedStyleSheets = this.constructor.elementStyles
|
||||
} else {
|
||||
const css = this.constructor.css
|
||||
if (css) {
|
||||
if (typeof css === 'string') {
|
||||
const styleSheet = new CSSStyleSheet()
|
||||
styleSheet.replaceSync(css)
|
||||
shadowRoot.adoptedStyleSheets = [styleSheet]
|
||||
} else if (Object.prototype.toString.call(css) === '[object Array]') {
|
||||
const styleSheets = []
|
||||
css.forEach(styleSheet => {
|
||||
if (typeof styleSheet === 'string') {
|
||||
const adoptedStyleSheet = new CSSStyleSheet()
|
||||
adoptedStyleSheet.replaceSync(styleSheet)
|
||||
styleSheets.push(adoptedStyleSheet)
|
||||
} else {
|
||||
styleSheets.push(styleSheet)
|
||||
}
|
||||
shadowRoot.adoptedStyleSheets = styleSheets
|
||||
})
|
||||
} else {
|
||||
shadowRoot.adoptedStyleSheets = [css]
|
||||
}
|
||||
this.constructor.elementStyles = shadowRoot.adoptedStyleSheets
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue