Skip to content
This repository was archived by the owner on May 19, 2023. It is now read-only.

Commit 29239d3

Browse files
authored
Merge pull request #126 from aidenybai/staging
2 parents 50a494d + 452232e commit 29239d3

File tree

7 files changed

+16
-83
lines changed

7 files changed

+16
-83
lines changed

.eslintignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
**/*.js
1+
**/*.js
2+
node_modules/

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
### 3kb library for tiny web apps.
44

5-
Sometimes, all you want to do is to try and do something—No boilerplate, bundlers, or complex build processes. Lucia aims to do this, providing an augmentation layer for your logic, allowing you to build just what you need with minimal effort and time.
5+
Sometimes, all you want to do is to try and do something—No boilerplate, bundlers, or complex build processes. Lucia aims to do this, providing an augmentation layer for your logic, allowing you to bind attributes to your HTML to add interactivity without writing any extra JavaScript.
66

77
[![CI](https://img.shields.io/github/workflow/status/aidenybai/lucia/test-runner?color=7460E1&labelColor=1D1E32&style=flat-square&label=build)](https://img.shields.io/github/workflow/status/aidenybai/lucia)
88
![Code Size](https://badgen.net/badgesize/brotli/https/unpkg.com/lucia?color=7460E1&labelColor=1D1E32&style=flat-square&label=size) ![NPM Version](https://img.shields.io/npm/v/lucia?color=7460E1&labelColor=1D1E32&style=flat-square) ![Code Coverage](https://img.shields.io/coveralls/github/aidenybai/lucia?color=7460E1&labelColor=1D1E32&style=flat-square)

README.zh-CN.md

-68
This file was deleted.

src/core/compile.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const isListRenderScope = (el: HTMLElement): boolean => {
1010
};
1111

1212
export const isUnderListRenderScope = (el: HTMLElement): boolean => {
13-
return el.parentElement && el.parentElement.hasAttribute(`${DIRECTIVE_PREFIX}for`);
13+
return !!el.parentElement && el.parentElement.hasAttribute(`${DIRECTIVE_PREFIX}for`);
1414
};
1515

1616
export const createASTNode = (el: HTMLElement, state: State): ASTNode | undefined => {
@@ -28,10 +28,11 @@ export const createASTNode = (el: HTMLElement, state: State): ASTNode | undefine
2828

2929
/* istanbul ignore next */
3030
export const collectRefs = (): Refs => {
31-
const refElements = document.querySelectorAll(`[${DIRECTIVE_PREFIX}ref]`);
31+
const refDirective = `${DIRECTIVE_PREFIX}ref`;
32+
const refElements = document.querySelectorAll(`[${refDirective}]`);
3233
const refs = {};
3334
refElements.forEach((refElement) => {
34-
const name = refElement.getAttribute(`${DIRECTIVE_PREFIX}ref`);
35+
const name = refElement.getAttribute(refDirective);
3536
if (name) refs[name] = refElement;
3637
});
3738
return refs;

src/core/directives/bind.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const bindDirective = ({ el, parts, data, state }: DirectiveProps): void
1313
if (typeof classes === 'string') {
1414
return el.setAttribute('class', formatAcceptableWhitespace(`${el.className} ${classes}`));
1515
// Accept providing an array of classes and appending them
16-
} else if (classes instanceof Array) {
16+
} else if (Array.isArray(classes)) {
1717
return el.setAttribute(
1818
'class',
1919
formatAcceptableWhitespace(`${el.className} ${classes.join(' ')}`)

src/core/reactive.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { State, Watchers } from '../models/structs';
44
export const arrayEquals = (firstArray: unknown[], secondArray: unknown[]): boolean => {
55
// Deep Array equality check
66
return (
7-
firstArray instanceof Array &&
8-
secondArray instanceof Array &&
7+
Array.isArray(firstArray) &&
8+
Array.isArray(secondArray) &&
99
firstArray.length === secondArray.length &&
1010
firstArray.every((value: unknown, i: number) => value === secondArray[i])
1111
);
@@ -30,14 +30,13 @@ export const reactive = (
3030
set(target: UnknownKV, key: string, value: unknown): boolean {
3131
// Currently double renderes - bad perf
3232
const hasArrayMutationKey = !isNaN(Number(key)) || key === 'length';
33-
const props = [key];
33+
const props = hasArrayMutationKey ? [] : [key];
3434

35-
if (target instanceof Array && hasArrayMutationKey) {
35+
if (Array.isArray(target) && hasArrayMutationKey) {
3636
const keys = Object.keys(state).filter((prop) => {
3737
return (
3838
// Find the array that equals the target
39-
state[prop] instanceof Array &&
40-
arrayEquals(state[prop] as unknown[], target as unknown[])
39+
Array.isArray(state[prop]) && arrayEquals(state[prop] as unknown[], target as unknown[])
4140
);
4241
});
4342
props.push(...keys);

yarn.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -5856,9 +5856,9 @@ trim-newlines@^3.0.0:
58565856
integrity sha512-C4+gOpvmxaSMKuEf9Qc134F1ZuOHVXKRbtEflf4NTtuuJDEIJ9p5PXsalL8SkeRw+qit1Mo+yuvMPAKwWg/1hA==
58575857

58585858
ts-jest@^26.4.2:
5859-
version "26.5.4"
5860-
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.5.4.tgz#207f4c114812a9c6d5746dd4d1cdf899eafc9686"
5861-
integrity sha512-I5Qsddo+VTm94SukBJ4cPimOoFZsYTeElR2xy6H2TOVs+NsvgYglW8KuQgKoApOKuaU/Ix/vrF9ebFZlb5D2Pg==
5859+
version "26.5.5"
5860+
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.5.5.tgz#e40481b6ee4dd162626ba481a2be05fa57160ea5"
5861+
integrity sha512-7tP4m+silwt1NHqzNRAPjW1BswnAhopTdc2K3HEkRZjF0ZG2F/e/ypVH0xiZIMfItFtD3CX0XFbwPzp9fIEUVg==
58625862
dependencies:
58635863
bs-logger "0.x"
58645864
buffer-from "1.x"

0 commit comments

Comments
 (0)