stuff
This commit is contained in:
parent
5d2082d799
commit
e5d171c9a0
|
@ -1617,14 +1617,14 @@
|
||||||
if (BDFDB.ReactUtils.isValidElement(node)) return node;
|
if (BDFDB.ReactUtils.isValidElement(node)) return node;
|
||||||
else if (!Node.prototype.isPrototypeOf(node)) return null;
|
else if (!Node.prototype.isPrototypeOf(node)) return null;
|
||||||
else if (node.nodeType == Node.TEXT_NODE) return node.nodeValue;
|
else if (node.nodeType == Node.TEXT_NODE) return node.nodeValue;
|
||||||
let attributes = {}, importantStyles = {};
|
let attributes = {}, importantStyles = [];
|
||||||
for (let attr of node.attributes) attributes[attr.name] = attr.value;
|
for (let attr of node.attributes) attributes[attr.name] = attr.value;
|
||||||
if (node.attributes.style) attributes.style = BDFDB.ObjectUtils.filter(node.style, n => node.style[n] && isNaN(parseInt(n)), true);
|
if (node.attributes.style) attributes.style = BDFDB.ObjectUtils.filter(node.style, n => node.style[n] && isNaN(parseInt(n)), true);
|
||||||
attributes.children = [];
|
attributes.children = [];
|
||||||
if (node.style && node.style.cssText) for (let propstr of node.style.cssText.split(";")) if (propstr.endsWith("!important")) {
|
if (node.style && node.style.cssText) for (let propstr of node.style.cssText.split(";")) if (propstr.endsWith("!important")) {
|
||||||
let key = propstr.split(":")[0];
|
let key = propstr.split(":")[0];
|
||||||
let camelprop = key.replace(/-([a-z]?)/g, (m, g) => g.toUpperCase());
|
let camelprop = key.replace(/-([a-z]?)/g, (m, g) => g.toUpperCase());
|
||||||
if (attributes.style[camelprop] != null) importantStyles[key] = attributes.style[camelprop];
|
if (attributes.style[camelprop] != null) importantStyles.push(key);
|
||||||
}
|
}
|
||||||
for (let child of node.childNodes) attributes.children.push(BDFDB.ReactUtils.elementToReact(child));
|
for (let child of node.childNodes) attributes.children.push(BDFDB.ReactUtils.elementToReact(child));
|
||||||
let reactEle = BDFDB.ReactUtils.createElement(node.tagName, attributes);
|
let reactEle = BDFDB.ReactUtils.createElement(node.tagName, attributes);
|
||||||
|
@ -1632,12 +1632,15 @@
|
||||||
return reactEle;
|
return reactEle;
|
||||||
};
|
};
|
||||||
BDFDB.ReactUtils.forceStyle = function (reactEle, styles) {
|
BDFDB.ReactUtils.forceStyle = function (reactEle, styles) {
|
||||||
if (!BDFDB.ReactUtils.isValidElement(reactEle) || !BDFDB.ObjectUtils.is(styles) || BDFDB.ObjectUtils.isEmpty(styles)) return;
|
if (!BDFDB.ReactUtils.isValidElement(reactEle) || !BDFDB.ObjectUtils.is(reactEle.props.style) || !BDFDB.ArrayUtils.is(styles) || !styles.length) return;
|
||||||
let ref = reactEle.ref;
|
let ref = reactEle.ref;
|
||||||
reactEle.ref = instance => {
|
reactEle.ref = instance => {
|
||||||
if (typeof ref == "function") ref(instance);
|
if (typeof ref == "function") ref(instance);
|
||||||
let node = BDFDB.ReactUtils.findDOMNode(instance);
|
let node = BDFDB.ReactUtils.findDOMNode(instance);
|
||||||
if (Node.prototype.isPrototypeOf(node)) for (let key in styles) node.style.setProperty(key, styles[key], "important");
|
if (Node.prototype.isPrototypeOf(node)) for (let key of styles) {
|
||||||
|
let propValue = reactEle.props.style[key.replace(/-([a-z]?)/g, (m, g) => g.toUpperCase())];
|
||||||
|
if (propValue != null) node.style.setProperty(key, propValue, "important");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
BDFDB.ReactUtils.findChildren = function (nodeOrInstance, config) {
|
BDFDB.ReactUtils.findChildren = function (nodeOrInstance, config) {
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue