Skip to content

Commit

Permalink
Remove all polyfills and updates dependencies
Browse files Browse the repository at this point in the history
BREAKING CHANGES:
Drop IE, Edge legacy and old browsers which are not support ES2015+ features
  • Loading branch information
anthony-redFox committed Aug 3, 2023
1 parent a78549e commit c20464d
Show file tree
Hide file tree
Showing 23 changed files with 3,897 additions and 4,852 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
.nyc_output
node_modules/
coverage/

3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
13 changes: 0 additions & 13 deletions babel-plugins.json

This file was deleted.

8 changes: 1 addition & 7 deletions cjs/classes/Component.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions cjs/hyper/render.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
5 changes: 2 additions & 3 deletions cjs/hyper/wire.js
Original file line number Diff line number Diff line change
@@ -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');

Expand Down
22 changes: 5 additions & 17 deletions cjs/index.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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);
Expand Down
20 changes: 8 additions & 12 deletions cjs/objects/Updates.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
30 changes: 30 additions & 0 deletions cjs/shared/utils.js
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion esm.js

Large diffs are not rendered by default.

9 changes: 2 additions & 7 deletions esm/classes/Component.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import CustomEvent from '@ungap/custom-event';
import Map from '@ungap/essential-map';
import WeakMap from '@ungap/weakmap';

// hyperHTML.Component is a very basic class
// able to create Custom Elements like components
// including the ability to listen to connect/disconnect
Expand All @@ -10,9 +6,8 @@ import WeakMap from '@ungap/weakmap';
// The main difference is that declared components
// will not automatically render on setState(...)
// to simplify state handling on render.
export default function Component() {
return this; // this is needed in Edge !!!
}
class Component {}
export default Component

// Component is lazily setup because it needs
// wire mechanism as lazy content
Expand Down
1 change: 0 additions & 1 deletion esm/hyper/render.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import WeakMap from '@ungap/weakmap';
import tta from '@ungap/template-tag-arguments';

import {OWNER_SVG_ELEMENT} from '../shared/constants.js';
Expand Down
1 change: 0 additions & 1 deletion esm/hyper/wire.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import WeakMap from '@ungap/weakmap';
import tta from '@ungap/template-tag-arguments';

import Wire from 'hyperhtml-wire';
Expand Down
12 changes: 0 additions & 12 deletions esm/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/*! (c) Andrea Giammarchi (ISC) */
import WeakMap from '@ungap/weakmap';
import WeakSet from '@ungap/essential-weakset';

import diff from 'domdiff';
import Component, {setup} from './classes/Component.js';
import Intent from './objects/Intent.js';
Expand All @@ -26,15 +23,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);
Expand Down
6 changes: 1 addition & 5 deletions esm/objects/Updates.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
import CustomEvent from '@ungap/custom-event';
import WeakSet from '@ungap/essential-weakset';
import isArray from '@ungap/is-array';
import createContent from '@ungap/create-content';

import disconnected from 'disconnected';
import domdiff from 'domdiff';
import domtagger from 'domtagger';
Expand All @@ -15,6 +10,7 @@ import {
OWNER_SVG_ELEMENT
} from '../shared/constants.js';

import { isArray, createContent } from '../shared/utils.js';
import Component from '../classes/Component.js';
import Intent from './Intent.js';

Expand Down
29 changes: 29 additions & 0 deletions esm/shared/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const {isArray} = Array;

export {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;
};

export const createContent = (text, type) => type == 'svg' ?
createSVG(text) : createHTML(text);
Loading

0 comments on commit c20464d

Please sign in to comment.