diff --git a/.gitignore b/.gitignore
index 3cb01d4d..12f4aaff 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
.DS_Store
+.nyc_output
node_modules/
coverage/
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 60ac2164..773c5d83 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,8 @@
# hyper(html) Changelog
+### v.3.0.0
+ * Drop IE, Edge legacy and old browsers which are not support ES2015+ features
+
### v.2.23
* monkey patched rollup generated code to export once the same module shared within sub-modules
diff --git a/babel-plugins.json b/babel-plugins.json
deleted file mode 100644
index d982204a..00000000
--- a/babel-plugins.json
+++ /dev/null
@@ -1,13 +0,0 @@
-[
- "check-es2015-constants",
- "transform-es2015-arrow-functions",
- "transform-es2015-block-scoped-functions",
- "transform-es2015-block-scoping",
- "transform-es2015-computed-properties",
- "transform-es2015-destructuring",
- "transform-es2015-duplicate-keys",
- "transform-es2015-function-name",
- "transform-es2015-literals",
- "transform-es2015-shorthand-properties",
- "transform-es2015-spread"
-]
\ No newline at end of file
diff --git a/cjs/classes/Component.js b/cjs/classes/Component.js
index 632986bf..94e8f254 100644
--- a/cjs/classes/Component.js
+++ b/cjs/classes/Component.js
@@ -1,8 +1,4 @@
'use strict';
-const CustomEvent = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/custom-event'));
-const Map = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/essential-map'));
-const WeakMap = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/weakmap'));
-
// hyperHTML.Component is a very basic class
// able to create Custom Elements like components
// including the ability to listen to connect/disconnect
@@ -11,9 +7,7 @@ const WeakMap = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* i
// The main difference is that declared components
// will not automatically render on setState(...)
// to simplify state handling on render.
-function Component() {
- return this; // this is needed in Edge !!!
-}
+class Component {}
Object.defineProperty(exports, '__esModule', {value: true}).default = Component
// Component is lazily setup because it needs
diff --git a/cjs/hyper/render.js b/cjs/hyper/render.js
index a401a66b..ab0c05a6 100644
--- a/cjs/hyper/render.js
+++ b/cjs/hyper/render.js
@@ -1,6 +1,5 @@
'use strict';
-const WeakMap = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/weakmap'));
-const tta = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/template-tag-arguments'));
+const tta = (m => /* c8 ignore start */ m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m /* c8 ignore stop */)(require('@ungap/template-tag-arguments'));
const {OWNER_SVG_ELEMENT} = require('../shared/constants.js');
const {Tagger} = require('../objects/Updates.js');
diff --git a/cjs/hyper/wire.js b/cjs/hyper/wire.js
index 139eaaba..110a5ee6 100644
--- a/cjs/hyper/wire.js
+++ b/cjs/hyper/wire.js
@@ -1,8 +1,7 @@
'use strict';
-const WeakMap = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/weakmap'));
-const tta = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/template-tag-arguments'));
+const tta = (m => /* c8 ignore start */ m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m /* c8 ignore stop */)(require('@ungap/template-tag-arguments'));
-const Wire = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('hyperhtml-wire'));
+const Wire = (m => /* c8 ignore start */ m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m /* c8 ignore stop */)(require('hyperhtml-wire'));
const {Tagger} = require('../objects/Updates.js');
diff --git a/cjs/index.js b/cjs/index.js
index 04ed734a..cdd8c399 100644
--- a/cjs/index.js
+++ b/cjs/index.js
@@ -1,16 +1,13 @@
'use strict';
/*! (c) Andrea Giammarchi (ISC) */
-const WeakMap = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/weakmap'));
-const WeakSet = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/essential-weakset'));
-
-const diff = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('domdiff'));
-const Component = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('./classes/Component.js'));
+const diff = (m => /* c8 ignore start */ m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m /* c8 ignore stop */)(require('domdiff'));
+const Component = (m => /* c8 ignore start */ m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m /* c8 ignore stop */)(require('./classes/Component.js'));
const {setup} = require('./classes/Component.js');
-const Intent = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('./objects/Intent.js'));
+const Intent = (m => /* c8 ignore start */ m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m /* c8 ignore stop */)(require('./objects/Intent.js'));
const {observe, Tagger} = require('./objects/Updates.js');
-const wire = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('./hyper/wire.js'));
+const wire = (m => /* c8 ignore start */ m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m /* c8 ignore stop */)(require('./hyper/wire.js'));
const {content, weakly} = require('./hyper/wire.js');
-const render = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('./hyper/render.js'));
+const render = (m => /* c8 ignore start */ m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m /* c8 ignore stop */)(require('./hyper/render.js'));
// all functions are self bound to the right context
// you can do the following
@@ -29,15 +26,6 @@ hyper.observe = observe;
hyper.tagger = tagger;
hyper.wire = wire;
-// exported as shared utils
-// for projects based on hyperHTML
-// that don't necessarily need upfront polyfills
-// i.e. those still targeting IE
-hyper._ = {
- WeakMap,
- WeakSet
-};
-
// the wire content is the lazy defined
// html or svg property of each hyper.Component
setup(content);
diff --git a/cjs/objects/Updates.js b/cjs/objects/Updates.js
index 0df2e324..e38f3a19 100644
--- a/cjs/objects/Updates.js
+++ b/cjs/objects/Updates.js
@@ -1,21 +1,17 @@
'use strict';
-const CustomEvent = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/custom-event'));
-const WeakSet = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/essential-weakset'));
-const isArray = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/is-array'));
-const createContent = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/create-content'));
-
-const disconnected = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('disconnected'));
-const domdiff = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('domdiff'));
-const domtagger = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('domtagger'));
-const hyperStyle = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('hyperhtml-style'));
-const Wire = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('hyperhtml-wire'));
+const disconnected = (m => /* c8 ignore start */ m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m /* c8 ignore stop */)(require('disconnected'));
+const domdiff = (m => /* c8 ignore start */ m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m /* c8 ignore stop */)(require('domdiff'));
+const domtagger = (m => /* c8 ignore start */ m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m /* c8 ignore stop */)(require('domtagger'));
+const hyperStyle = (m => /* c8 ignore start */ m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m /* c8 ignore stop */)(require('hyperhtml-style'));
+const Wire = (m => /* c8 ignore start */ m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m /* c8 ignore stop */)(require('hyperhtml-wire'));
const {
CONNECTED, DISCONNECTED, DOCUMENT_FRAGMENT_NODE, OWNER_SVG_ELEMENT
} = require('../shared/constants.js');
-const Component = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('../classes/Component.js'));
-const Intent = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('./Intent.js'));
+const { isArray, createContent } = require('../shared/utils.js');
+const Component = (m => /* c8 ignore start */ m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m /* c8 ignore stop */)(require('../classes/Component.js'));
+const Intent = (m => /* c8 ignore start */ m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m /* c8 ignore stop */)(require('./Intent.js'));
const componentType = Component.prototype.nodeType;
const wireType = Wire.prototype.nodeType;
diff --git a/cjs/shared/utils.js b/cjs/shared/utils.js
index ad9a93a7..6e0c70b6 100644
--- a/cjs/shared/utils.js
+++ b/cjs/shared/utils.js
@@ -1 +1,31 @@
'use strict';
+const {isArray} = Array;
+
+exports.isArray = isArray;
+
+const {
+ createDocumentFragment,
+ createElement,
+ createElementNS,
+} = new Proxy({}, {
+ get: (_, method) => document[method].bind(document)
+});
+
+const createHTML = html => {
+ const template = createElement('template');
+ template.innerHTML = html;
+ return template.content;
+};
+
+let xml;
+const createSVG = svg => {
+ if (!xml) xml = createElementNS('http://www.w3.org/2000/svg', 'svg');
+ xml.innerHTML = svg;
+ const content = createDocumentFragment();
+ content.append(...xml.childNodes);
+ return content;
+};
+
+const createContent = (text, type) => type == 'svg' ?
+ createSVG(text) : createHTML(text);
+exports.createContent = createContent;
\ No newline at end of file
diff --git a/esm.js b/esm.js
index 1ded632c..b935be52 100644
--- a/esm.js
+++ b/esm.js
@@ -1,3 +1,3 @@
-/*! (c) Andrea Giammarchi (ISC) */var hyperHTML=function(N){"use strict";var t={};try{t.WeakMap=WeakMap}catch(e){t.WeakMap=function(t,e){var n=e.defineProperty,r=e.hasOwnProperty,i=a.prototype;return i.delete=function(e){return this.has(e)&&delete e[this._]},i.get=function(e){return this.has(e)?e[this._]:void 0},i.has=function(e){return r.call(e,this._)},i.set=function(e,t){return n(e,this._,{configurable:!0,value:t}),this},a;function a(e){n(this,"_",{value:"_@ungap/weakmap"+t++}),e&&e.forEach(o,this)}function o(e){this.set(e[0],e[1])}}(Math.random(),Object)}var s=t.WeakMap,i={};try{i.WeakSet=WeakSet}catch(e){!function(e,t){var n=r.prototype;function r(){t(this,"_",{value:"_@ungap/weakmap"+e++})}n.add=function(e){return this.has(e)||t(e,this._,{value:!0,configurable:!0}),this},n.has=function(e){return this.hasOwnProperty.call(e,this._)},n.delete=function(e){return this.has(e)&&delete e[this._]},i.WeakSet=r}(Math.random(),Object.defineProperty)}function m(e,t,n,r,i,a){for(var o=("selectedIndex"in t),u=o;ro;)--c;l=u+r-c;var m=Array(l),y=s[c];for(--n;y;){for(var b=y.newi,w=y.oldi;b
${{user}}
`; - define: function define(intent, callback) { + define: (intent, callback) => { if (intent.indexOf('-') < 0) { if (!(intent in intents)) { length = keys.push(intent); } - intents[intent] = callback; } else { attributes[intent] = callback; } }, + // this method is used internally as last resort // to retrieve a value out of an object - invoke: function invoke(object, callback) { - for (var i = 0; i < length; i++) { - var key = keys[i]; - + invoke: (object, callback) => { + for (let i = 0; i < length; i++) { + let key = keys[i]; if (hasOwnProperty.call(object, key)) { return intents[key](object[key], callback); } @@ -743,142 +791,81 @@ var hyperHTML = (function (document) { } }; - var isArray = Array.isArray || - /* istanbul ignore next */ - function (toString) { - /* istanbul ignore next */ - var $ = toString.call([]); - /* istanbul ignore next */ - - return function isArray(object) { - return toString.call(object) === $; - }; - }({}.toString); - - /*! (c) Andrea Giammarchi - ISC */ - var createContent = function (document) { - - var FRAGMENT = 'fragment'; - var TEMPLATE = 'template'; - var HAS_CONTENT = ('content' in create(TEMPLATE)); - var createHTML = HAS_CONTENT ? function (html) { - var template = create(TEMPLATE); - template.innerHTML = html; - return template.content; - } : function (html) { - var content = create(FRAGMENT); - var template = create(TEMPLATE); - var childNodes = null; - - if (/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(html)) { - var selector = RegExp.$1; - template.innerHTML = '