@getlang/lib
Advanced tools
Comparing version 0.0.7 to 0.0.8
@@ -1,7 +0,7 @@ | ||
import type { AnyNode } from 'domhandler'; | ||
import type { AnyHtmlNode } from 'domhandler'; | ||
import './html/patch-dom.js'; | ||
import './html/types.ext.js'; | ||
import './html/types.js'; | ||
export declare const parse: (html: string) => AnyNode; | ||
export declare const select: (el: AnyNode, selector: string, expand: boolean) => AnyNode | AnyNode[] | undefined; | ||
export declare const toValue: (el: AnyNode) => string; | ||
export declare const parse: (html: string) => AnyHtmlNode; | ||
export declare const select: (el: AnyHtmlNode, selector: string, expand: boolean) => AnyHtmlNode | AnyHtmlNode[] | undefined; | ||
export declare const toValue: (el: AnyHtmlNode) => string; |
{ | ||
"name": "@getlang/lib", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -1,2 +0,2 @@ | ||
import type { AnyNode } from 'domhandler' | ||
import type { AnyHtmlNode } from 'domhandler' | ||
import { parse as parse5 } from 'parse5' | ||
@@ -17,7 +17,7 @@ import { adapter } from 'parse5-htmlparser2-tree-adapter' | ||
export const parse = (html: string): AnyNode => { | ||
export const parse = (html: string): AnyHtmlNode => { | ||
return parse5(html, { treeAdapter: adapter }) | ||
} | ||
const selectXpath = (el: AnyNode, selector: string, expand: boolean) => { | ||
const selectXpath = (el: AnyHtmlNode, selector: string, expand: boolean) => { | ||
try { | ||
@@ -45,3 +45,3 @@ const parseXpath = new xpath.XPathParser() | ||
const selectCss = (el: AnyNode, selector: string, expand: boolean) => { | ||
const selectCss = (el: AnyHtmlNode, selector: string, expand: boolean) => { | ||
try { | ||
@@ -59,3 +59,3 @@ parseCss(selector) | ||
export const select = (el: AnyNode, selector: string, expand: boolean) => { | ||
export const select = (el: AnyHtmlNode, selector: string, expand: boolean) => { | ||
return selector.startsWith('xpath:') | ||
@@ -66,3 +66,3 @@ ? selectXpath(el, selector.slice(6), expand) | ||
export const toValue = (el: AnyNode) => { | ||
export const toValue = (el: AnyHtmlNode) => { | ||
let str = '' | ||
@@ -69,0 +69,0 @@ if (el.nodeType === 2) { |
declare module '@getlang/xpath' { | ||
import type { AnyNode } from 'domhandler' | ||
import type { AnyHtmlNode } from 'domhandler' | ||
export function select(selector: string, node: AnyNode): Array<AnyNode> | ||
export function select( | ||
selector: string, | ||
node: AnyHtmlNode, | ||
): Array<AnyHtmlNode> | ||
@@ -6,0 +9,0 @@ export class XPathParser { |
import type { ElementType } from 'domelementtype' | ||
import type * as dh from 'domhandler' | ||
import { Node, type AnyNode } from 'domhandler' | ||
declare module 'domhandler' { | ||
class Attribute extends dh.Node { | ||
class Attribute extends Node { | ||
type: ElementType.Text | ||
@@ -11,3 +11,3 @@ get nodeType(): 2 | ||
export type AnyNode = dh.ParentNode | dh.ChildNode | Attribute | ||
type AnyHtmlNode = AnyNode | Attribute | ||
} |
Sorry, the diff of this file is not supported yet
34325
635