Skip to content

Commit

Permalink
polish
Browse files Browse the repository at this point in the history
  • Loading branch information
chicoxyzzy committed Oct 11, 2022
1 parent 381eaa1 commit eeaff1c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
31 changes: 12 additions & 19 deletions index.js
Expand Up @@ -21,7 +21,7 @@ export class Tonic extends window.HTMLElement {
static _reg = {};
static _stylesheetRegistry = [];
static _index = 0;
static version = "14.1.5";
static version = "14.3.0";
static SPREAD = /\.\.\.\s?(__\w+__\w+__)/g;
static ESC = /["&'<>`/]/g;
static AsyncFunctionGenerator = async function* () {
Expand All @@ -45,13 +45,12 @@ export class Tonic extends window.HTMLElement {
get isTonicComponent() {
return true;
}

static _createId() {
return `tonic${Tonic._index++}`;
}
static _normalizeAttrs (o, x = {}) {
[...o].forEach(o => (x[o.name] = o.value))
return x
static _normalizeAttrs(o, x = {}) {
[...o].forEach((o2) => x[o2.name] = o2.value);
return x;
}
_checkId() {
const _id = super.id;
Expand Down Expand Up @@ -94,14 +93,11 @@ export class Tonic extends window.HTMLElement {
el = el.parentElement;
return el.matches(s) ? el : el.closest(s);
}

static getTagName (camelName) {
return camelName.match(/[A-Z][a-z0-9]*/g).join('-').toLowerCase()
static getTagName(camelName) {
return camelName.match(/[A-Z][a-z0-9]*/g).join("-").toLowerCase();
}

static getPropertyNames (proto) {
const props = []

static getPropertyNames(proto) {
const props = [];
while (proto && proto !== Tonic.prototype) {
props.push(...Object.getOwnPropertyNames(proto));
proto = Object.getPrototypeOf(proto);
Expand All @@ -113,8 +109,8 @@ export class Tonic extends window.HTMLElement {
if (!hasValidName) {
throw Error("Mangling. https://bit.ly/2TkJ6zP");
}

if (!htmlName) htmlName = Tonic.getTagName(c.name)
if (!htmlName)
htmlName = Tonic.getTagName(c.name);
if (!Tonic.ssr && window.customElements.get(htmlName)) {
throw new Error(`Cannot Tonic.add(${c.name}, '${htmlName}') twice`);
}
Expand Down Expand Up @@ -166,7 +162,7 @@ export class Tonic extends window.HTMLElement {
return this._placehold([...o]);
case "[object Array]": {
if (o.every((x) => x.isTonicTemplate && !x.unsafe)) {
return new TonicTemplate(o.join("\n"), null, false);
return new TonicTemplate(o.join(""), null, false);
}
return this._prop(o);
}
Expand Down Expand Up @@ -245,9 +241,7 @@ export class Tonic extends window.HTMLElement {
return this._drainIterator(target, iterator);
});
}

_set (target, render, content = '') {
this.willRender && this.willRender()
_set(target, render, content = "") {
for (const node of target.querySelectorAll(Tonic._tags)) {
if (!node.isTonicComponent)
continue;
Expand Down Expand Up @@ -364,5 +358,4 @@ export class Tonic extends window.HTMLElement {
delete Tonic._children[this._id];
}
}

export default Tonic;
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -8,7 +8,7 @@
"test": "npm run build && standard && esbuild --bundle test/index.js | tape-run",
"test:open": "npm run build && esbuild --bundle test/index.js | tape-run --browser chrome --keep-open",
"build": "esbuild src/index.js --define:VERSION=\\\"$npm_package_version\\\" --outfile=index.js ",
"pub": "npm pub && npm publish --registry https://npm.pkg.github.com"
"pub": "npm run test && npm publish --registry=https://registry.npmjs.org && npm publish --registry https://npm.pkg.github.com"
},
"main": "index.js",
"type": "module",
Expand Down

0 comments on commit eeaff1c

Please sign in to comment.