Skip to content

Commit

Permalink
[fix] 3 detail bugs
Browse files Browse the repository at this point in the history
[optimize] upgrade to Husky 9
  • Loading branch information
TechQuery committed Feb 9, 2024
1 parent 22c9f33 commit 4b872f0
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 57 deletions.
4 changes: 0 additions & 4 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
#!/bin/sh

. "$(dirname "$0")/_/husky.sh"

npm test
4 changes: 0 additions & 4 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
#!/bin/sh

. "$(dirname "$0")/_/husky.sh"

npm run build
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dom-renderer",
"version": "2.1.0",
"version": "2.1.3",
"license": "LGPL-3.0-or-later",
"author": "shiy2008@gmail.com",
"description": "A light-weight DOM Renderer supports Web components standard & TypeScript language",
Expand Down Expand Up @@ -29,8 +29,8 @@
},
"devDependencies": {
"@types/jest": "^29.5.12",
"@types/node": "^18.19.14",
"husky": "^8.0.3",
"@types/node": "^18.19.15",
"husky": "^9.0.10",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"lint-staged": "^15.2.2",
Expand All @@ -56,7 +56,7 @@
},
"browserslist": "> 0.5%, last 2 versions, not dead, IE 11",
"scripts": {
"prepare": "husky install",
"prepare": "husky",
"test": "lint-staged && jest",
"parcel": "tsc -p tsconfig.json && mv dist/jsx-runtime.* . && cp jsx-runtime.js jsx-dev-runtime.js && mv dist/dist/* dist/ && rm -rf dist/dist",
"build": "rm -rf dist/ docs/ && typedoc && npm run parcel",
Expand Down
78 changes: 39 additions & 39 deletions pnpm-lock.yaml

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

6 changes: 2 additions & 4 deletions source/dist/DOMRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,8 @@ export class DOMRenderer {
for (const oldNode of [...root.childNodes]) {
const index = newNodes.indexOf(oldNode);

if (index < 0) {
oldNode.remove();
continue;
} else if (index === 0) {
if (index < 0) continue;
else if (index === 0) {
newNodes.shift();
continue;
}
Expand Down
1 change: 1 addition & 0 deletions source/jsx-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export function jsx(
}

export const jsxs = jsx;
export const jsxDEV = jsx;

/**
* @see {@link https://babeljs.io/docs/babel-plugin-transform-react-jsx#react-automatic-runtime-1}
Expand Down
6 changes: 4 additions & 2 deletions test/DOMRenderer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,19 @@ describe('DOM Renderer', () => {
});

it('should update DOM children without keys', () => {
const newNode = renderer.patch(
var newNode = renderer.patch(
{ ...root },
{ ...root, children: [{ children: [new VNode({ tagName: 'i' })] }] }
);
expect(document.body.innerHTML).toBe('<i></i>');

renderer.patch(newNode, {
newNode = renderer.patch(newNode, {
...root,
children: [{ children: [new VNode({ tagName: 'a' })] }]
});
expect(document.body.innerHTML).toBe('<a></a>');

renderer.patch(newNode, root);
});

it('should not invoke duplicated Connected Callbacks during updating', () => {
Expand Down

0 comments on commit 4b872f0

Please sign in to comment.