Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"globals": {
"globalThis": false
},
"reportUnusedDisableDirectives": true,
"rules": {
"class-methods-use-this": "off",
"consistent-return": "off",
Expand All @@ -26,32 +27,32 @@
"no-continue": "off",
"no-multi-assign": "off",
"no-nested-ternary": "off",
"no-new-object": "off",
"no-object-constructor": "error",
"no-param-reassign": "off",
"no-plusplus": "off",
"no-restricted-syntax": "off",
"no-restricted-syntax": ["error", "LabeledStatement", "WithStatement"],
"no-return-assign": "off",
"no-shadow": "off",
"no-throw-literal": "off",
"no-underscore-dangle": "off",
"no-unused-expressions": "off",
"no-use-before-define": "off",
"no-void": "off",
"prefer-const": "off",
"prefer-destructuring": ["error", { "object": true, "array": false }],
"prefer-rest-params": "off",
"prefer-promise-reject-errors": "off",
"symbol-description": "off",
"import/extensions": "off",
"import/extensions": ["error", "always"],
"import/no-extraneous-dependencies": "off",
"import/prefer-default-export": "off"
},
"overrides": [
{
"files": "types/**/*.ts",
"files": "**/*.{ts,tsx}",
"extends": ["airbnb-typescript/base", "prettier"],
"rules": {
"@typescript-eslint/no-shadow": "off",
"@typescript-eslint/no-unused-expressions": "off",
"@typescript-eslint/no-use-before-define": "off",
"import/extensions": ["error", "always"],
"import/no-cycle": "off"
}
}
Expand Down
Empty file modified .husky/pre-commit
100644 → 100755
Empty file.
Empty file modified .husky/pre-push
100644 → 100755
Empty file.
5 changes: 4 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/.circleci
/.github
/.husky
/.vscode
/*.log
/node_modules
/docs
Expand All @@ -7,4 +9,5 @@
/jsconfig.json
/karma.conf.js
/rollup.config.js
/web-test-runner.config.mjs
**/tests/
4 changes: 2 additions & 2 deletions html.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,13 @@ const build = function(statics) {

const CACHE = new Map();

function html(statics) {
function html(statics, ...values) {
let tmp = CACHE;

tmp = evaluate(
createElement,
tmp.get(statics) || (tmp.set(statics, (tmp = build(statics))), tmp),
arguments,
[statics, ...values],
[],
);

Expand Down
4 changes: 2 additions & 2 deletions html/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { createElement } from "../src/core.js";

const CACHE = new Map();

export function html(statics) {
export function html(statics, ...values) {
let tmp = CACHE;

tmp = evaluate(
createElement,
tmp.get(statics) || (tmp.set(statics, (tmp = build(statics))), tmp),
arguments,
[statics, ...values],
[],
);

Expand Down
4 changes: 1 addition & 3 deletions jsx-runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import { createElement } from "./src/core.js";
export { Fragment } from "./src/core.js";

/**
*
* @param {any} type
* @param {any} props
* @param {any} [key ]
* @returns
* @param {any} [key]
*/
export const jsx = (type, props, key) => {
if (props == undefined) {
Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 4 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"ssr": "node ssr/tests/ssr.js",
"test:w": "web-test-runner --watch",
"build:html": "rollup -c",
"prepare": "npm run test:ts && npm run test",
"prepare": "husky install && npm run test:ts && npm run test",
"lint": "eslint .",
"hook:push": "npm run lint && npm run test",
"hook:commit": "npm run lint"
Expand All @@ -104,9 +104,9 @@
"devDependencies": {
"@esm-bundle/chai": "^4.3.4-fix.0",
"@rollup/plugin-node-resolve": "^13.3.0",
"@types/chai": "^4.2.18",
"@types/mocha": "^8.0.0",
"@web/test-runner": "^0.13.27",
"@types/chai": "^4.3.9",
"@types/mocha": "^8.2.3",
"@web/test-runner": "^0.13.31",
"eslint": "^8.52.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^17.1.0",
Expand All @@ -118,9 +118,6 @@
"typescript": "^5.2.2"
},
"prettier": {
"endOfLine": "lf",
"semi": true,
"singleQuote": false,
"tabWidth": 4
}
}
6 changes: 4 additions & 2 deletions src/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export const useConsumer = (id) => {
};

/**
*
* @type {import("context").UseContext}
*/
export const useContext = (context) => {
Expand All @@ -92,7 +91,10 @@ export const createContext = (value) => {
/**
* @type {import("context").ComponentContext<any>}
*/
const context = () => void useProvider(Context, useHost().current);
const context = () => {
useProvider(Context, useHost().current);
return undefined;
};

context.props = {
value: {
Expand Down
4 changes: 2 additions & 2 deletions src/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { options } from "./options.js";
/**
* It is used only if the browser supports adoptedStyleSheets.
* caches the CSSStyleSheet using the css as a reference to the instance
* @type {{[id:string]:import("core").Sheet}}
* @type {{ [id: string]: import("core").Sheet }}
*/
const SHEETS = {};

/**
* Create a Style from a string
* @param {TemplateStringsArray} template
* @param {...any} args
* @param {any[]} args
*/
export function css(template, ...args) {
const cssText = (template.raw || template).reduce(
Expand Down
20 changes: 11 additions & 9 deletions src/element/custom-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { setPrototype, transformValue } from "./set-prototype.js";
export { Any, createType } from "./set-prototype.js";

let ID = 0;

/**
*
* @param {Element & {dataset?:object}} node
* @returns {string|number}
* @param {Element & { dataset?: object }} node
* @returns {string | number}
*/
const getHydrateId = (node) => {
const id = (node?.dataset || {})?.hydrate || "";
Expand All @@ -24,11 +24,11 @@ const getHydrateId = (node) => {
*/
export const c = (component, base) => {
/**
* @type {import("./set-prototype").Attrs}
* @type {import("./set-prototype.js").Attrs}
*/
const attrs = {};
/**
* @type {import("./set-prototype").Values}
* @type {import("./set-prototype.js").Values}
*/
const values = {};

Expand All @@ -46,7 +46,9 @@ export const c = (component, base) => {
super();
this._setup();
this._render = () => component({ ...this._props });
for (const prop in values) this[prop] = values[prop];
for (const prop in values) {
this[prop] = values[prop];
}
}

/**
Expand Down Expand Up @@ -104,7 +106,7 @@ export const c = (component, base) => {
};
});

this.symbolId = this.symbolId || Symbol();
this.symbolId = this.symbolId || Symbol(className);

const hooks = createHooks(
() => this.update(),
Expand Down Expand Up @@ -192,8 +194,8 @@ export const c = (component, base) => {
/**
* @this {import("dom").AtomicoThisInternal}
* @param {string} attr
* @param {(string|null)} oldValue
* @param {(string|null)} value
* @param {string | null} oldValue
* @param {string | null} value
*/
attributeChangedCallback(attr, oldValue, value) {
if (attrs[attr]) {
Expand Down
1 change: 0 additions & 1 deletion src/element/errors.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export class Error {
/**
*
* @param {HTMLElement} target
* @param {string} message
* @param {string} value
Expand Down
Loading