Skip to content

Commit

Permalink
Merge branch 'release/v0.13.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
holtwick committed May 16, 2024
2 parents fb99763 + 4c0e78c commit b617757
Show file tree
Hide file tree
Showing 24 changed files with 31 additions and 37 deletions.
6 changes: 6 additions & 0 deletions env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
declare namespace JSX {
/** See https://www.typescriptlang.org/docs/handbook/jsx.html#intrinsic-elements */
interface IntrinsicElements {
[elemName: string]: any
}
}
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "zeed-dom",
"type": "module",
"version": "0.13.0",
"version": "0.13.1",
"description": "🌱 Lightweight offline DOM",
"author": {
"name": "Dirk Holtwick",
Expand Down Expand Up @@ -45,9 +45,11 @@
"main": "dist/index.node.cjs",
"module": "dist/index.browser.js",
"typings": "dist/index.node.d.ts",
"types": "dist/index.node.d.ts",
"files": [
"dist",
"jsx-runtime"
"jsx-runtime",
"env.d.ts"
],
"engines": {
"node": ">=14.13.1"
Expand All @@ -70,9 +72,9 @@
"entities": "^4.5.0"
},
"devDependencies": {
"@antfu/eslint-config": "^2.17.0",
"@antfu/eslint-config": "^2.18.0",
"@antfu/ni": "^0.21.12",
"@types/node": "^20.12.11",
"@types/node": "^20.12.12",
"@vitest/coverage-v8": "^1.6.0",
"c8": "^9.1.0",
"eslint": "^9.2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/encoding.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('encoding', () => {
expect(escapeHTML('<and> &')).toEqual('&lt;and&gt; &amp;')
})

it("should decode", () => {
it('should decode', () => {
expect(unescapeHTML('&amp; &#x3A; &copy;')).toEqual('& : ©')
})
})
2 changes: 1 addition & 1 deletion src/encoding.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// import { decode } from './encoding-he'
import { decodeHTML as decode} from 'entities'
import { decodeHTML as decode } from 'entities'

export function escapeHTML(text: string) {
return text
Expand Down
2 changes: 0 additions & 2 deletions src/h.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// (C)opyright 2021-07-20 Dirk Holtwick, holtwick.it. All rights reserved.

import { hArgumentParser } from './h'

describe('h', () => {
Expand Down
2 changes: 0 additions & 2 deletions src/h.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Copyright (c) 2020 Dirk Holtwick. All rights reserved. https://holtwick.de/copyright

import type { VDocument, VDocumentFragment, VElement } from './vdom'

/*
Expand Down
2 changes: 0 additions & 2 deletions src/html.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Copyright (c) 2020 Dirk Holtwick. All rights reserved. https://holtwick.de/copyright

// Special cases:
// 1. <noop> is an element that is not printed out, can be used to create a list of elements
// 2. Attribute name '__' gets transformed to ':' for namespace emulation
Expand Down
4 changes: 2 additions & 2 deletions src/htmlparser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
// 2. and then \s*=\s*
// 3. and value can be "value" | 'value' | value
// 4. 2 and 3 are optional
const attrRe = /([^=\s]+)(\s*=\s*(("([^"]*)")|('([^']*)')|[^>\s]+))?/gm
const attrRe = /([^=\s]+)(\s*=\s*(("([^"]*)")|('([^']*)')|[^>\s]+))?/g
const endTagRe = /^<\/([^>\s]+)[^>]*>/m
// start tag, like <a href="link"> <img/>
// 1. must start with <tagName
// 2. optional attrbutes
// 3. /> or >
const startTagRe = /^<([^>\s\/]+)((\s+[^=>\s]+(\s*=\s*(("[^"]*")|('[^']*')|[^>\s]+))?)*)\s*\/?\s*>/m
const startTagRe = /^<([^>\s/]+)((\s+[^=>\s]+(\s*=\s*(("[^"]*")|('[^']*')|[^>\s]+))?)*)\s*(?:\/\s*)?>/m
const selfCloseTagRe = /\s*\/\s*>\s*$/m

/**
Expand Down
2 changes: 1 addition & 1 deletion src/index.browser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// (C)opyright 2021-07-20 Dirk Holtwick, holtwick.it. All rights reserved.
export * from './jsx-intrinsicelements'

export * from './vdom'
export * from './h'
Expand Down
2 changes: 0 additions & 2 deletions src/index.node.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
// (C)opyright 2023 Dirk Holtwick, holtwick.it. All rights reserved.

export * from './index.browser'
export { handleHTMLFile } from './node'
8 changes: 8 additions & 0 deletions src/jsx-intrinsicelements.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* eslint-disable ts/no-namespace */

export declare namespace JSX {
/** See https://www.typescriptlang.org/docs/handbook/jsx.html#intrinsic-elements */
interface IntrinsicElements {
[elemName: string]: any
}
}
2 changes: 2 additions & 0 deletions src/jsx-runtime.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { h } from './html'

export * from './jsx-intrinsicelements'

// See
// https://esbuild.github.io/api/#jsx-import-source
// https://www.typescriptlang.org/tsconfig/#jsxImportSource
Expand Down
2 changes: 0 additions & 2 deletions src/serialize-markdown.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// (C)opyright 2021-07-20 Dirk Holtwick, holtwick.it. All rights reserved.

import { serializeMarkdown } from './serialize-markdown'
import { serializePlaintext } from './serialize-plaintext'
import { createHTMLDocument, h } from './vdom'
Expand Down
2 changes: 1 addition & 1 deletion src/serialize-markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ function serialize(node: VNode | VElement, context: SerializeContext = {
}

export function serializeMarkdown(node: VNode): string {
return `${serialize(node).replace(/\n\n+/gim, '\n\n').trim()}\n`
return `${serialize(node).replace(/\n{2,}/g, '\n\n').trim()}\n`
}
2 changes: 1 addition & 1 deletion src/serialize-plaintext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ function serialize(node: VNode | VElement, context: SerializeContext = {
}

export function serializePlaintext(node: VNode): string {
return `${serialize(node).replace(/\n\n+/gim, '\n\n').trim()}\n`
return `${serialize(node).replace(/\n{2,}/g, '\n\n').trim()}\n`
}
2 changes: 0 additions & 2 deletions src/serialize-safehtml.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// (C)opyright 2021-07-20 Dirk Holtwick, holtwick.it. All rights reserved.

import { serializeSafeHTML } from './serialize-safehtml'
import { parseHTML } from './vdomparser'

Expand Down
2 changes: 0 additions & 2 deletions src/tidy.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// (C)opyright 2021-07-20 Dirk Holtwick, holtwick.it. All rights reserved.

import { tidyDOM } from './tidy'
import { createHTMLDocument, h } from './vdom'

Expand Down
2 changes: 0 additions & 2 deletions src/tidy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// (C)opyright 2021-07-20 Dirk Holtwick, holtwick.it. All rights reserved.

import type { VDocument } from './vdom'
import { VNode, VTextNode } from './vdom'

Expand Down
2 changes: 0 additions & 2 deletions src/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// (C)opyright 2021-07-20 Dirk Holtwick, holtwick.it. All rights reserved.

import { removeBodyContainer } from './utils'
import { createHTMLDocument } from './vdom'

Expand Down
2 changes: 0 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// (C)opyright 2021-07-20 Dirk Holtwick, holtwick.it. All rights reserved.

import type { VNodeQuery } from './vdom'
import { VDocumentFragment } from './vdom'

Expand Down
1 change: 0 additions & 1 deletion src/vcss.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// (C)opyright 2021-07-20 Dirk Holtwick, holtwick.it. All rights reserved.

import { matchSelector } from './vcss'
import { createHTMLDocument, h } from './vdom'
Expand Down
2 changes: 0 additions & 2 deletions src/vcss.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// (C)opyright 2021-07-20 Dirk Holtwick, holtwick.it. All rights reserved.

import { parse } from 'css-what'
import type { VElement } from './vdom'

Expand Down
2 changes: 1 addition & 1 deletion src/vdom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const DEFAULTS = {
} as any

function toCamelCase(s: string): string {
return s.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g, (_m, chr) => chr.toUpperCase())
return s.toLowerCase().replace(/[^a-z0-9]+(.)/gi, (_m, chr) => chr.toUpperCase())
}

export class VNode {
Expand Down
3 changes: 1 addition & 2 deletions src/xml.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// (C)opyright 2021-07-20 Dirk Holtwick, holtwick.it. All rights reserved.

import './jsx-runtime'
import { hArgumentParser } from './h'
import { markup } from './html'

Expand Down

0 comments on commit b617757

Please sign in to comment.