driver-dom
Advanced tools
Comparing version 2.0.9-0 to 2.0.9
@@ -111,2 +111,15 @@ (function () { | ||
}); | ||
/** | ||
* Camelize CSS property. | ||
* Vendor prefixes should begin with a capital letter. | ||
* For example: | ||
* background-color -> backgroundColor | ||
* -webkit-transition -> webkitTransition | ||
*/ | ||
var camelizeStyleName = cached(function (name) { | ||
return name.replace(/-([a-z])/gi, function (s, g) { | ||
return g.toUpperCase(); | ||
}); | ||
}); | ||
var isDimensionalProp = cached(function (prop) { | ||
@@ -238,7 +251,10 @@ return !NON_DIMENSIONAL_REG.test(prop); | ||
// Remove invalid style prop, and direct reset style to child avoid diff style | ||
for (var _i = 0, l = hydrationChild.style.length; _i < l; _i++) { | ||
var stylePropName = hydrationChild.style[_i]; | ||
// Set style to empty will change the index of style, so here need to traverse style backwards | ||
for (var l = hydrationChild.style.length; 0 < l; l--) { | ||
// Prop name get from node style is hyphenated, eg: background-color | ||
var stylePropName = hydrationChild.style[l - 1]; | ||
var camelizedStyleName = camelizeStyleName(stylePropName); | ||
if (!propValue[stylePropName]) { | ||
hydrationChild.style[stylePropName] = EMPTY; | ||
if (propValue[camelizedStyleName] == null) { | ||
hydrationChild.style[camelizedStyleName] = EMPTY; | ||
} | ||
@@ -444,3 +460,3 @@ } | ||
var DriverDOM = ({ | ||
var DriverDOM = { | ||
__proto__: null, | ||
@@ -469,3 +485,3 @@ setViewportWidth: setViewportWidth, | ||
removeChildren: removeChildren | ||
}); | ||
}; | ||
@@ -472,0 +488,0 @@ if (typeof module !== 'undefined') module.exports = DriverDOM;else self.DriverDOM = DriverDOM; |
@@ -1,2 +0,2 @@ | ||
!function(){require("./warning");var n=/[-+]?\d*\.?\d+(rpx)/g,t=/opa|ntw|ne[ch]|ex(?:s|g|n|p|$)|^ord|zoo|grid|orp|ows|mnc|^columns$|bs|erim|onit/i,r=/^on[A-Z]/,i="dangerouslySetInnerHTML",e="__html",u="innerHTML",y="className",_="class",b="style",o="textContent",g="createElement",f="createComment",c="createTextNode",a="setAttribute",w="removeAttribute",T="http://www.w3.org/2000/svg",A="",l="__i",C="__a",E=A,M=!1,L=!1,s=750,v=4;function d(e){return function(e,n){var t=Math.pow(10,n+1);return 10*Math.round(Math.floor(e*t)/10)/t}(parseFloat(e)/(s/100),v)+"vw"}function m(n){var t=Object.create(null);return function(e){return t[e]||(t[e]=n(e))}}var p=m(function(e){return function(e){return n.test(e)}(e)?function(e){return e.replace(n,d)}(e):e}),h=m(function(e){return!t.test(e)}),N=m(function(e){return r.test(e)});function P(e){return null==e[l]&&(e[l]=0),e.childNodes[e[l]++]}function x(e,n){if(!L||e[C])return n.appendChild(e)}function j(e,n,t){(t=t||n.parentNode).replaceChild(e,n)}function B(e,n,t){(t=t||n.parentNode).insertBefore(e,n)}function H(e,n,t){return e.addEventListener(n,t)}function O(n,t,r){if(t===i&&n[u]!==r[e])return n[u]=r[e];if(t===y&&(t=_),t in n)try{n[t]=r}catch(e){n[a](t,r)}else n[a](t,r)}function R(e,n,t,r){for(var i in void 0===r&&(r=!0),n){var u=n[i],o=void 0;"number"==typeof u&&h(i)?t?(o=u+"rpx",r&&(o=p(o))):o=u+"px":o=r?p(u):u,"-"===i[0]&&"-"===i[1]?e.style.setProperty(i,o):e.style[i]=o}}var S={__proto__:null,setViewportWidth:function(e){s=e},setUnitPrecision:function(e){v=e},setDecimalPixelTransformer:function(){},setTagNamePrefix:function(e){E=e},createBody:function(){return document.body},createEmpty:function(e){var n,t=e._parent;if(L){var r=P(t);if(r){if(8===r.nodeType)return r;j(n=document[f](A),r,t)}else(n=document[f](A))[C]=!0}else n=document[f](A);return n},createText:function(e,n){var t,r=n._parent;if(L){var i=P(r);if(i){if(3===i.nodeType)return e!==i[o]&&(i[o]=e),i;j(t=document[c](e),i,r)}else(t=document[c](e))[C]=!0}else t=document[c](e);return t},updateText:function(e,n){e[o]=n},createElement:function(n,e,t,r,i){void 0===i&&(i=!0);var u,o=t._parent;M="svg"===n||o&&o.namespaceURI===T;var f=null;function c(){if(M)u=document.createElementNS(T,n);else if(E){var e="function"==typeof e?e(n):e;u=document[g](e+n)}else u=document[g](n)}if(L)if(f=P(o))if(n===f.nodeName.toLowerCase()){for(var a=f.attributes,l=a.length;l--;){var s=a[l].name,v=e[s];if(s===_&&null==e[y]&&null==v||s===b&&(null==v||0===Object.keys(v).length)||s!==_&&s!==b&&null==v)f[w](s);else if(s===b)for(var d=0,m=f.style.length;d<m;d++){var p=f.style[d];v[p]||(f.style[p]=A)}}u=f}else c(),j(u,f,o);else c(),u[C]=!0;else c();for(var h in e){var x=e[h];"children"!==h&&null!=x&&(h===b?R(u,x,r,i):N(h)?H(u,h.slice(2).toLowerCase(),x):O(u,h,x))}return u},appendChild:x,removeChild:function(e,n){(n=n||e.parentNode)&&n.removeChild(e)},replaceChild:j,insertAfter:function(e,n,t){t=t||n.parentNode;var r=n.nextSibling;r?r!==e&&B(e,r,t):x(e,t)},insertBefore:B,addEventListener:H,removeEventListener:function(e,n,t){return e.removeEventListener(n,t)},removeAttribute:function(e,n){if(n===i)return e[u]=null;if(n===y&&(n=_),n in e)try{e[n]=null}catch(e){}e[w](n)},setAttribute:O,setStyle:R,beforeRender:function(e){L=e.hydrate},afterRender:function(e){L&&(!function e(n){var t=n.childNodes.length,r=n[l]||0;if(0<t-r)for(var i=t-1;r<=i;i--)n.removeChild(n.childNodes[i]);for(var u=n.childNodes.length-1;0<=u;u--)e(n.childNodes[u])}(e.container),L=!1)},removeChildren:function(e){e.textContent=A}};"undefined"!=typeof module?module.exports=S:self.DriverDOM=S}(); | ||
!function(){require("./warning");var n=/[-+]?\d*\.?\d+(rpx)/g,t=/opa|ntw|ne[ch]|ex(?:s|g|n|p|$)|^ord|zoo|grid|orp|ows|mnc|^columns$|bs|erim|onit/i,r=/^on[A-Z]/,i="dangerouslySetInnerHTML",e="__html",u="innerHTML",g="className",x="class",y="style",o="textContent",_="createElement",f="createComment",c="createTextNode",l="setAttribute",b="removeAttribute",w="http://www.w3.org/2000/svg",T="",a="__i",A="__a",C=T,E=!1,M=!1,s=750,v=4;function d(e){return 10*Math.round(Math.floor(parseFloat(e)/(s/100)*(n=Math.pow(10,v+1)))/10)/n+"vw";var n}function m(n){var t=Object.create(null);return function(e){return t[e]||(t[e]=n(e))}}var p=m(function(e){return n.test(e)?e.replace(n,d):e}),L=m(function(e){return e.replace(/-([a-z])/gi,function(e,n){return n.toUpperCase()})}),h=m(function(e){return!t.test(e)}),N=m(function(e){return r.test(e)});function P(e){return null==e[a]&&(e[a]=0),e.childNodes[e[a]++]}function j(e,n){if(!M||e[A])return n.appendChild(e)}function z(e,n,t){(t=t||n.parentNode).replaceChild(e,n)}function B(e,n,t){(t=t||n.parentNode).insertBefore(e,n)}function H(e,n,t){return e.addEventListener(n,t)}function O(n,t,r){if(t===i&&n[u]!==r[e])return n[u]=r[e];if(t===g&&(t=x),t in n)try{n[t]=r}catch(e){n[l](t,r)}else n[l](t,r)}function R(e,n,t,r){for(var i in void 0===r&&(r=!0),n){var u=n[i],o=void 0;"number"==typeof u&&h(i)?t?(o=u+"rpx",r&&(o=p(o))):o=u+"px":o=r?p(u):u,"-"===i[0]&&"-"===i[1]?e.style.setProperty(i,o):e.style[i]=o}}var S={__proto__:null,setViewportWidth:function(e){s=e},setUnitPrecision:function(e){v=e},setDecimalPixelTransformer:function(){},setTagNamePrefix:function(e){C=e},createBody:function(){return document.body},createEmpty:function(e){var n,t=e._parent;if(M){var r=P(t);if(r){if(8===r.nodeType)return r;z(n=document[f](T),r,t)}else(n=document[f](T))[A]=!0}else n=document[f](T);return n},createText:function(e,n){var t,r=n._parent;if(M){var i=P(r);if(i){if(3===i.nodeType)return e!==i[o]&&(i[o]=e),i;z(t=document[c](e),i,r)}else(t=document[c](e))[A]=!0}else t=document[c](e);return t},updateText:function(e,n){e[o]=n},createElement:function(n,e,t,r,i){void 0===i&&(i=!0);var u,o=t._parent;E="svg"===n||o&&o.namespaceURI===w;var f=null;function c(){if(E)u=document.createElementNS(w,n);else if(C){var e="function"==typeof e?e(n):e;u=document[_](e+n)}else u=document[_](n)}if(M)if(f=P(o))if(n===f.nodeName.toLowerCase()){for(var l=f.attributes,a=l.length;a--;){var s=l[a].name,v=e[s];if(s===x&&null==e[g]&&null==v||s===y&&(null==v||0===Object.keys(v).length)||s!==x&&s!==y&&null==v)f[b](s);else if(s===y)for(var d=f.style.length;0<d;d--){var m=L(f.style[d-1]);null==v[m]&&(f.style[m]=T)}}u=f}else c(),z(u,f,o);else c(),u[A]=!0;else c();for(var p in e){var h=e[p];"children"!==p&&null!=h&&(p===y?R(u,h,r,i):N(p)?H(u,p.slice(2).toLowerCase(),h):O(u,p,h))}return u},appendChild:j,removeChild:function(e,n){(n=n||e.parentNode)&&n.removeChild(e)},replaceChild:z,insertAfter:function(e,n,t){t=t||n.parentNode;var r=n.nextSibling;r?r!==e&&B(e,r,t):j(e,t)},insertBefore:B,addEventListener:H,removeEventListener:function(e,n,t){return e.removeEventListener(n,t)},removeAttribute:function(e,n){if(n===i)return e[u]=null;if(n===g&&(n=x),n in e)try{e[n]=null}catch(e){}e[b](n)},setAttribute:O,setStyle:R,beforeRender:function(e){M=e.hydrate},afterRender:function(e){M&&(!function e(n){var t=n.childNodes.length,r=n[a]||0;if(0<t-r)for(var i=t-1;r<=i;i--)n.removeChild(n.childNodes[i]);for(var u=n.childNodes.length-1;0<=u;u--)e(n.childNodes[u])}(e.container),M=!1)},removeChildren:function(e){e.textContent=T}};"undefined"!=typeof module?module.exports=S:self.DriverDOM=S}(); | ||
//# sourceMappingURL=driver-dom.min.js.map |
@@ -115,2 +115,15 @@ (function (global, factory) { | ||
}); | ||
/** | ||
* Camelize CSS property. | ||
* Vendor prefixes should begin with a capital letter. | ||
* For example: | ||
* background-color -> backgroundColor | ||
* -webkit-transition -> webkitTransition | ||
*/ | ||
var camelizeStyleName = cached(function (name) { | ||
return name.replace(/-([a-z])/gi, function (s, g) { | ||
return g.toUpperCase(); | ||
}); | ||
}); | ||
var isDimensionalProp = cached(function (prop) { | ||
@@ -242,7 +255,10 @@ return !NON_DIMENSIONAL_REG.test(prop); | ||
// Remove invalid style prop, and direct reset style to child avoid diff style | ||
for (var _i = 0, l = hydrationChild.style.length; _i < l; _i++) { | ||
var stylePropName = hydrationChild.style[_i]; | ||
// Set style to empty will change the index of style, so here need to traverse style backwards | ||
for (var l = hydrationChild.style.length; 0 < l; l--) { | ||
// Prop name get from node style is hyphenated, eg: background-color | ||
var stylePropName = hydrationChild.style[l - 1]; | ||
var camelizedStyleName = camelizeStyleName(stylePropName); | ||
if (!propValue[stylePropName]) { | ||
hydrationChild.style[stylePropName] = EMPTY; | ||
if (propValue[camelizedStyleName] == null) { | ||
hydrationChild.style[camelizedStyleName] = EMPTY; | ||
} | ||
@@ -249,0 +265,0 @@ } |
@@ -9,3 +9,3 @@ var didWarnInvalidHydration = false; | ||
return; | ||
} // shoudd not warn for replace comment, bescause it may be a placeholder from server | ||
} // should not warn for replace comment, bescause it may be a placeholder from server | ||
@@ -12,0 +12,0 @@ |
@@ -16,3 +16,3 @@ "use strict"; | ||
return; | ||
} // shoudd not warn for replace comment, bescause it may be a placeholder from server | ||
} // should not warn for replace comment, bescause it may be a placeholder from server | ||
@@ -19,0 +19,0 @@ |
{ | ||
"name": "driver-dom", | ||
"version": "2.0.9-0", | ||
"version": "2.0.9", | ||
"description": "DOM driver for Rax", | ||
@@ -5,0 +5,0 @@ "license": "BSD-3-Clause", |
@@ -15,3 +15,3 @@ let didWarnInvalidHydration = false; | ||
// shoudd not warn for replace comment, bescause it may be a placeholder from server | ||
// should not warn for replace comment, bescause it may be a placeholder from server | ||
if (serverNode.nodeType === 8) { | ||
@@ -18,0 +18,0 @@ return; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
209553
3020
1