From 6262e1d7426c2ac3fefde6f8a3e6ebe8b8086630 Mon Sep 17 00:00:00 2001
From: webreflection
Date: Fri, 10 May 2019 13:47:34 +0200
Subject: [PATCH] Fix #358 - Cleanup accessors before dropping the attribute
---
cjs/objects/Updates.js | 11 ++++++-----
esm.js | 2 +-
esm/objects/Updates.js | 11 ++++++-----
index.js | 12 +++++-------
min.js | 2 +-
test/edge.html | 6 +++---
umd.js | 2 +-
7 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/cjs/objects/Updates.js b/cjs/objects/Updates.js
index 081e1c6f..157c5c05 100644
--- a/cjs/objects/Updates.js
+++ b/cjs/objects/Updates.js
@@ -130,12 +130,13 @@ Tagger.prototype = {
return newValue => {
if (oldValue !== newValue) {
oldValue = newValue;
- if (node[name] !== newValue) {
- node[name] = newValue;
- if (newValue == null) {
- node.removeAttribute(name);
- }
+ if (node[name] !== newValue && newValue == null) {
+ // cleanup on null to avoid silly IE/Edge bug
+ node[name] = '';
+ node.removeAttribute(name);
}
+ else
+ node[name] = newValue;
}
};
}
diff --git a/esm.js b/esm.js
index f54026c2..10fc0d22 100644
--- a/esm.js
+++ b/esm.js
@@ -1,7 +1,7 @@
/*! (c) Andrea Giammarchi (ISC) */var hyperHTML=function(e){"use strict";function t(){return this}/*! (c) Andrea Giammarchi - ISC */
function n(e){return e.join(te).replace(de,o).replace(he,r)}function r(e,t,n,r){return"<"+t+n.replace(pe,i)+r}function i(e,t,n){return t+(n||'"')+ee+(n||'"')}function o(e,t,n){return ae.test(t)?e:"<"+t+n+">"+t+">"}function a(e,t,n,r){return{name:r,node:t,path:n,type:e}}function u(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var g=Array(l),y=s[c];for(--n;y;){for(var b=y,w=b.newi,N=b.oldi;n>w;)g[--l]=1,--n;for(;a>N;)g[--l]=-1,--a;g[--l]=0,--n,--a,y=y.prev}for(;n>=t;)g[--l]=1,--n;for(;a>=o;)g[--l]=-1,--a;return g},W=function(e,t,n,r,i,o,a){var u,c,l,s,f,h,d,p=n+o,v=[];e:for(u=0;u<=p;u++){if(u>50)return null;for(d=u-1,f=u?v[u-1]:[0,0],h=v[u]=[],c=-u;c<=u;c+=2){for(s=c===-u||c!==u&&f[d+c-1]=0;u--){for(;s>0&&l>0&&a(r[i+s-1],e[t+l-1]);)m[g--]=0,s--,l--;if(!u)break;d=u-1,f=u?v[u-1]:[0,0],c=s-l,c===-u||c!==u&&f[d+c-1]>>0;n",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML="",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),Q={};try{Q.WeakMap=WeakMap}catch(WeakMap){Q.WeakMap=function(e,t){function n(t){i(this,"_",{value:"_@ungap/weakmap"+e++}),t&&t.forEach(r,this)}function r(e){this.set(e[0],e[1])}var i=t.defineProperty,o=t.hasOwnProperty,a=n.prototype;return a["delete"]=function(e){return this.has(e)&&delete e[this._]},a.get=function(e){return this.has(e)?e[this._]:void 0},a.has=function(e){return o.call(e,this._)},a.set=function(e,t){return i(e,this._,{configurable:!0,value:t}),this},n}(Math.random(),Object)}var U=Q.WeakMap,X=function(e,t,n,r,i){var o="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],i=r.length,o=0;t&&o
',e.content.childNodes[0].getAttribute("tabindex")==ee)})(e.createElement("template"))||(ee="_dt: "+ee.slice(1,-1)+";")}catch(Ze){}var te="\x3c!--"+ee+"--\x3e",ne=8,re=1,ie=3,oe=/^(?:style|textarea)$/i,ae=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,ue=" \\f\\n\\r\\t",ce="[^"+ue+"\\/>\"'=]+",le="["+ue+"]+"+ce,se="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",fe="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|"+ce.replace("\\/","")+"))?)",he=new RegExp(se+le+fe+"+)(["+ue+"]*/?>)","g"),de=new RegExp(se+le+fe+"*)(["+ue+"]*/>)","g"),pe=new RegExp("("+le+"\\s*=\\s*)(['\"]?)"+te+"\\2","gi"),ve={};try{ve.Map=Map}catch(Map){ve.Map=function(){function e(e){return-1<(t=n.indexOf(e))}var t=0,n=[],r=[];return{"delete":function(i){var o=e(i);return o&&(n.splice(t,1),r.splice(t,1)),o},get:function(n){return e(n)?r[t]:void 0},has:function(t){return e(t)},set:function(i,o){return r[e(i)?t:n.push(i)-1]=o,this}}}}var me=ve.Map,ge=new U,ye=new U,be=function(){function e(e,t,n){return t+"-"+n.toLowerCase()}function t(e,t){var n;return t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style")),n.value="",e.setAttributeNode(n),r(n,!0)}function n(t){var n,r=[];for(n in t)r.push(n.replace(o,e),":",t[n],";");return r.join("")}function r(e,t){var r,o;return function(a){var u,c,l,s;switch(typeof a){case"object":if(a){if("object"===r){if(!t&&o!==a)for(c in o)c in a||(e[c]="")}else t?e.value="":e.cssText="";u=t?{}:e;for(c in a)s=a[c],l="number"!=typeof s||i.test(c)?s:s+"px",!t&&/^--/.test(c)?u.setProperty(c,l):u[c]=l;r="object",t?e.value=n(o=u):o=a;break}default:o!=a&&(r="string",o=a,t?e.value=a||"":e.cssText=a||"")}}}var i=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,o=/([^A-Z])([A-Z]+)/g;return function(e,n){return"ownerSVGElement"in e?t(e,n):r(e.style,!1)}}(),we=function(e,t){function n(t){var n=this.childNodes=e.call(t,0);this.firstChild=n[0],this.lastChild=n[n.length-1],this.ownerDocument=n[0].ownerDocument,this._=null}return t=n.prototype,t.ELEMENT_NODE=1,t.nodeType=111,t.remove=function(e){var t=this.childNodes,n=this.firstChild,r=this.lastChild;if(this._=null,e&&2===t.length)r.parentNode.removeChild(r);else{var i=this.ownerDocument.createRange();i.setStartBefore(e?t[1]:n),i.setEndAfter(r),i.deleteContents()}return n},t.valueOf=function(e){var t=this._,n=null==t;if(n&&(t=this._=this.ownerDocument.createDocumentFragment()),n||e)for(var r=this.childNodes,i=0,o=r.length;i {
if (oldValue !== newValue) {
oldValue = newValue;
- if (node[name] !== newValue) {
- node[name] = newValue;
- if (newValue == null) {
- node.removeAttribute(name);
- }
+ if (node[name] !== newValue && newValue == null) {
+ // cleanup on null to avoid silly IE/Edge bug
+ node[name] = '';
+ node.removeAttribute(name);
}
+ else
+ node[name] = newValue;
}
};
}
diff --git a/index.js b/index.js
index 1d521aa7..69664ac4 100644
--- a/index.js
+++ b/index.js
@@ -1549,13 +1549,11 @@ var hyperHTML = (function (document) {
if (oldValue !== newValue) {
oldValue = newValue;
- if (node[name] !== newValue) {
- node[name] = newValue;
-
- if (newValue == null) {
- node.removeAttribute(name);
- }
- }
+ if (node[name] !== newValue && newValue == null) {
+ // cleanup on null to avoid silly IE/Edge bug
+ node[name] = '';
+ node.removeAttribute(name);
+ } else node[name] = newValue;
}
};
} else if (name in Intent.attributes) {
diff --git a/min.js b/min.js
index 1a37fa65..aa2df12b 100644
--- a/min.js
+++ b/min.js
@@ -1,5 +1,5 @@
/*! (c) Andrea Giammarchi (ISC) */var hyperHTML=function(e){"use strict";function t(){return this}/*! (c) Andrea Giammarchi - ISC */
function n(e){return e.join(te).replace(de,o).replace(he,r)}function r(e,t,n,r){return"<"+t+n.replace(pe,i)+r}function i(e,t,n){return t+(n||'"')+ee+(n||'"')}function o(e,t,n){return ae.test(t)?e:"<"+t+n+">"+t+">"}function a(e,t,n,r){return{name:r,node:t,path:n,type:e}}function u(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var g=Array(l),y=s[c];for(--n;y;){for(var b=y,w=b.newi,N=b.oldi;n>w;)g[--l]=1,--n;for(;a>N;)g[--l]=-1,--a;g[--l]=0,--n,--a,y=y.prev}for(;n>=t;)g[--l]=1,--n;for(;a>=o;)g[--l]=-1,--a;return g},W=function(e,t,n,r,i,o,a){var u,c,l,s,f,h,d,p=n+o,v=[];e:for(u=0;u<=p;u++){if(u>50)return null;for(d=u-1,f=u?v[u-1]:[0,0],h=v[u]=[],c=-u;c<=u;c+=2){for(s=c===-u||c!==u&&f[d+c-1]=0;u--){for(;s>0&&l>0&&a(r[i+s-1],e[t+l-1]);)m[g--]=0,s--,l--;if(!u)break;d=u-1,f=u?v[u-1]:[0,0],c=s-l,c===-u||c!==u&&f[d+c-1]>>0;n",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML="",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),Q={};try{Q.WeakMap=WeakMap}catch(WeakMap){Q.WeakMap=function(e,t){function n(t){i(this,"_",{value:"_@ungap/weakmap"+e++}),t&&t.forEach(r,this)}function r(e){this.set(e[0],e[1])}var i=t.defineProperty,o=t.hasOwnProperty,a=n.prototype;return a["delete"]=function(e){return this.has(e)&&delete e[this._]},a.get=function(e){return this.has(e)?e[this._]:void 0},a.has=function(e){return o.call(e,this._)},a.set=function(e,t){return i(e,this._,{configurable:!0,value:t}),this},n}(Math.random(),Object)}var U=Q.WeakMap,X=function(e,t,n,r,i){var o="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],i=r.length,o=0;t&&o',e.content.childNodes[0].getAttribute("tabindex")==ee)})(e.createElement("template"))||(ee="_dt: "+ee.slice(1,-1)+";")}catch(Ze){}var te="\x3c!--"+ee+"--\x3e",ne=8,re=1,ie=3,oe=/^(?:style|textarea)$/i,ae=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,ue=" \\f\\n\\r\\t",ce="[^"+ue+"\\/>\"'=]+",le="["+ue+"]+"+ce,se="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",fe="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|"+ce.replace("\\/","")+"))?)",he=new RegExp(se+le+fe+"+)(["+ue+"]*/?>)","g"),de=new RegExp(se+le+fe+"*)(["+ue+"]*/>)","g"),pe=new RegExp("("+le+"\\s*=\\s*)(['\"]?)"+te+"\\2","gi"),ve={};try{ve.Map=Map}catch(Map){ve.Map=function(){function e(e){return-1<(t=n.indexOf(e))}var t=0,n=[],r=[];return{"delete":function(i){var o=e(i);return o&&(n.splice(t,1),r.splice(t,1)),o},get:function(n){return e(n)?r[t]:void 0},has:function(t){return e(t)},set:function(i,o){return r[e(i)?t:n.push(i)-1]=o,this}}}}var me=ve.Map,ge=new U,ye=new U,be=function(){function e(e,t,n){return t+"-"+n.toLowerCase()}function t(e,t){var n;return t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style")),n.value="",e.setAttributeNode(n),r(n,!0)}function n(t){var n,r=[];for(n in t)r.push(n.replace(o,e),":",t[n],";");return r.join("")}function r(e,t){var r,o;return function(a){var u,c,l,s;switch(typeof a){case"object":if(a){if("object"===r){if(!t&&o!==a)for(c in o)c in a||(e[c]="")}else t?e.value="":e.cssText="";u=t?{}:e;for(c in a)s=a[c],l="number"!=typeof s||i.test(c)?s:s+"px",!t&&/^--/.test(c)?u.setProperty(c,l):u[c]=l;r="object",t?e.value=n(o=u):o=a;break}default:o!=a&&(r="string",o=a,t?e.value=a||"":e.cssText=a||"")}}}var i=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,o=/([^A-Z])([A-Z]+)/g;return function(e,n){return"ownerSVGElement"in e?t(e,n):r(e.style,!1)}}(),we=function(e,t){function n(t){var n=this.childNodes=e.call(t,0);this.firstChild=n[0],this.lastChild=n[n.length-1],this.ownerDocument=n[0].ownerDocument,this._=null}return t=n.prototype,t.ELEMENT_NODE=1,t.nodeType=111,t.remove=function(e){var t=this.childNodes,n=this.firstChild,r=this.lastChild;if(this._=null,e&&2===t.length)r.parentNode.removeChild(r);else{var i=this.ownerDocument.createRange();i.setStartBefore(e?t[1]:n),i.setEndAfter(r),i.deleteContents()}return n},t.valueOf=function(e){var t=this._,n=null==t;if(n&&(t=this._=this.ownerDocument.createDocumentFragment()),n||e)for(var r=this.childNodes,i=0,o=r.length;iEdge test
-
+