Socket
Socket
Sign inDemoInstall

@simple-dom/interface

Package Overview
Dependencies
Maintainers
5
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@simple-dom/interface - npm Package Compare versions

Comparing version 1.4.0-alpha.dc2f50c1 to 1.4.0-alpha.f90dc13

119

index.d.ts

@@ -1,3 +0,3 @@

export const enum SimpleNodeType {
RAW = -1,
export const enum NodeType {
RAW_NODE = -1,
ELEMENT_NODE = 1,

@@ -11,7 +11,43 @@ TEXT_NODE = 3,

export interface SimpleNode {
// TODO
// readonly namespaceURI: string;
export const enum InsertPosition {
beforebegin = 'beforebegin',
afterbegin = 'afterbegin',
beforeend = 'beforeend',
afterend = 'afterend',
}
readonly nodeType: SimpleNodeType;
/**
* https://infra.spec.whatwg.org/#namespaces
*/
export const enum Namespace {
HTML = 'http://www.w3.org/1999/xhtml',
MathML = 'http://www.w3.org/1998/Math/MathML',
SVG = 'http://www.w3.org/2000/svg',
XLink = 'http://www.w3.org/1999/xlink',
XML = 'http://www.w3.org/XML/1998/namespace',
XMLNS = 'http://www.w3.org/2000/xmlns/'
}
/**
* elements that are supported in HTML5 that have a namespace but no prefix
*/
export type ElementNamespace = Namespace.HTML | Namespace.SVG | Namespace.MathML;
/**
* attributes handled in HTML5 that get prefix and namespace
*/
export type AttrNamespace = Namespace.XLink | Namespace.XMLNS | Namespace.XML;
export type SimpleNode =
SimpleRawHTMLSection |
SimpleElement |
SimpleText |
SimpleComment |
SimpleDocument |
SimpleDocumentType |
SimpleDocumentFragment;
export interface SimpleNodeBase {
readonly ownerDocument: SimpleDocument;
readonly nodeType: NodeType;
readonly nodeName: string;

@@ -21,2 +57,4 @@

// in the Element iterface these are readonly but we need them read/write
// we could check ownerDocument === this and cast them.
parentNode: SimpleNode | null;

@@ -42,2 +80,5 @@ previousSibling: SimpleNode | null;

export interface SimpleAttr {
readonly namespaceURI: AttrNamespace | null;
readonly prefix: string | null;
readonly localName: string;
readonly name: string;

@@ -53,26 +94,44 @@ readonly specified: true;

export interface SimpleElement extends SimpleNode {
readonly nodeType: SimpleNodeType.ELEMENT_NODE;
export interface SimpleElement extends SimpleNodeBase {
readonly nodeType: NodeType.ELEMENT_NODE;
readonly nodeValue: null;
readonly namespaceURI: ElementNamespace;
readonly tagName: string;
readonly attributes: SimpleAttrs;
insertAdjacentHTML(position: InsertPosition, html: string): void;
getAttribute(name: string): string | null;
getAttributeNS(namespaceURI: AttrNamespace | null, localName: string): string | null;
removeAttribute(name: string): void;
// TODO: removeAttributeNS(namespaceURI: string | null, localName: string): void;
setAttribute(name: string, value: any | undefined | null): void;
// TODO: setAttributeNS(namespaceURI: string | null, qualifiedName: string, value: string): void;
removeAttributeNS(namespaceURI: AttrNamespace | null, qualifiedName: string): void;
setAttribute(name: string, value: string): void;
setAttributeNS(namespaceURI: AttrNamespace | null, qualifiedName: string, value: string): void;
}
export interface SimpleDocumentFragment extends SimpleNode {
nodeType: SimpleNodeType.DOCUMENT_FRAGMENT_NODE;
export interface SimpleDocumentType extends SimpleNodeBase {
readonly nodeType: NodeType.DOCUMENT_TYPE_NODE;
readonly nodeValue: null;
}
export interface SimpleDocument extends SimpleNode {
nodeType: SimpleNodeType.DOCUMENT_NODE;
export interface SimpleDocumentFragment extends SimpleNodeBase {
readonly nodeType: NodeType.DOCUMENT_FRAGMENT_NODE;
readonly nodeValue: null;
}
export interface SimpleDocument extends SimpleNodeBase {
readonly nodeType: NodeType.DOCUMENT_NODE;
readonly nodeValue: null;
readonly doctype: SimpleDocumentType;
readonly documentElement: SimpleElement;
readonly head: SimpleElement;
readonly body: SimpleElement;
createElement(tag: string): SimpleElement;
createElementNS(namespace: ElementNamespace, name: string): SimpleElement;
// TODO createElementNS(namespace: Namespace, tag: string): Element;
createTextNode(text: string): SimpleText;

@@ -83,18 +142,21 @@ createComment(data: string): SimpleComment;

// should we just add insertAdjacentHTML?
// it isn't parsed so the DOM tree wouldn't reflect it
// but would work the same for serializing
/**
* @deprecated
*/
createRawHTMLSection?(html: string): SimpleRawHTMLSection;
}
export interface SimpleRawHTMLSection extends SimpleNode {
nodeType: SimpleNodeType.RAW;
export interface SimpleRawHTMLSection extends SimpleNodeBase {
readonly nodeType: NodeType.RAW_NODE;
readonly nodeValue: string;
}
export interface SimpleText extends SimpleNode {
nodeType: SimpleNodeType.TEXT_NODE;
export interface SimpleText extends SimpleNodeBase {
readonly nodeType: NodeType.TEXT_NODE;
nodeValue: string;
}
export interface SimpleComment extends SimpleNode {
nodeType: SimpleNodeType.COMMENT_NODE;
export interface SimpleComment extends SimpleNodeBase {
readonly nodeType: NodeType.COMMENT_NODE;
nodeValue: string;
}

@@ -109,2 +171,4 @@

export interface SimpleChildNodes {
readonly length: number;
[index: number]: SimpleNode;
item(index: number): SimpleNode | null;

@@ -114,3 +178,3 @@ }

export interface SerializableNode {
readonly nodeType: SimpleNodeType;
readonly nodeType: number;
readonly nodeName: string;

@@ -135,3 +199,4 @@ readonly nodeValue: string | null;

export interface SerializableElement extends SerializableNode {
readonly namespaceURI: string | null;
readonly attributes: SerializableAttrs;
}
{
"name": "@simple-dom/interface",
"version": "1.4.0-alpha.dc2f50c1",
"description": "A simple HTML parser",
"version": "1.4.0-alpha.f90dc13",
"description": "Simple DOM typescript interfaces",
"keywords": [
"dom",
"html",
"typescript",
"types"
],
"license": "MIT",
"author": "Kris Selden",
"license": "MIT",
"files": [
"index.d.ts"
],
"keywords": [
"html",
"dom"
],
"types": "index.d.ts",
"repository": "https://github.com/ember-fastboot/simple-dom/tree/master/packages/@simple-dom/interface",
"types": "dist/types/index.d.ts",
"publishConfig": {
"access": "public"
}
},
"gitHead": "f90dc1337500e6f08662ab849a1236e1dea61cbb"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc