mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-01-31 05:57:33 +00:00
Added typings for domutils (#33866)
* Added new types for domelementtype * Adding types for module domutils * Updating PULL_REQUEST_TEMPLATE.md * Revert changes to .github/PULL_REQUEST_TEMPLATE.md * Update test and documentation * Removed namespace and fixed tests
This commit is contained in:
parent
e3037f9ba8
commit
02db5ccb68
9
types/domutils/domutils-tests.ts
Normal file
9
types/domutils/domutils-tests.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import * as DomUtils from 'domutils';
|
||||
|
||||
const elem = { name: 'elem' };
|
||||
const next = { name: 'next' };
|
||||
const child = { name: 'child' };
|
||||
|
||||
DomUtils.append(elem, next);
|
||||
DomUtils.appendChild(elem, child);
|
||||
DomUtils.getName(elem);
|
||||
127
types/domutils/index.d.ts
vendored
Normal file
127
types/domutils/index.d.ts
vendored
Normal file
@ -0,0 +1,127 @@
|
||||
// Type definitions for domutils 1.7
|
||||
// Project: https://github.com/FB55/domutils#readme
|
||||
// Definitions by: Johan Davidsson <https://github.com/johandavidson>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
import { DomElement } from "domhandler";
|
||||
/***
|
||||
* Append an element after another
|
||||
*
|
||||
* @argument elem The element to append to
|
||||
* @argument next The element be added
|
||||
*/
|
||||
export function append(elem: DomElement, next: DomElement): void;
|
||||
/***
|
||||
* Append a child to an element
|
||||
*
|
||||
* @argument elem The element to append to
|
||||
* @argument child The element to be added as a child
|
||||
*/
|
||||
export function appendChild(elem: DomElement, child: DomElement): void;
|
||||
/***
|
||||
* Compare the position of one node against another node in any other document.
|
||||
* The return value is a bitmask with the following values:
|
||||
*
|
||||
* document order:
|
||||
* > There is an ordering, document order, defined on all the nodes in the
|
||||
* > document corresponding to the order in which the first character of the
|
||||
* > XML representation of each node occurs in the XML representation of the
|
||||
* > document after expansion of general entities. Thus, the document element
|
||||
* > node will be the first node. Element nodes occur before their children.
|
||||
* > Thus, document order orders element nodes in order of the occurrence of
|
||||
* > their start-tag in the XML (after expansion of entities). The attribute
|
||||
* > nodes of an element occur after the element and before its children. The
|
||||
* > relative order of attribute nodes is implementation-dependent./
|
||||
*
|
||||
* Source:
|
||||
* http://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-document-order
|
||||
* @argument nodaA The first node to use in the comparison
|
||||
* @argument nodeB The second node to use in the comparison
|
||||
*
|
||||
* @return A bitmask describing the input nodes' relative position.
|
||||
*
|
||||
* See http://dom.spec.whatwg.org/#dom-node-comparedocumentposition for
|
||||
* a description of these values.
|
||||
*/
|
||||
export function compareDocumentPosition(nodeA: DomElement, nodeB: DomElement): number;
|
||||
export function existsOne(test: any, elems: DomElement[]): boolean;
|
||||
export function filter(test: any, element: DomElement, recurse: boolean, limit: number): DomElement[];
|
||||
export function find(test: any, elems: DomElement[], recurse: boolean, limit: number): DomElement[];
|
||||
export function findAll(test: any, rootElems: DomElement[]): DomElement[];
|
||||
export function findOne(test: any, elems: DomElement[]): DomElement;
|
||||
export function findOneChild(test: any, elems: DomElement[]): DomElement;
|
||||
export function getAttributeValue(elem: DomElement, name: string): string;
|
||||
export function getChildren(elem: DomElement): DomElement[];
|
||||
/***
|
||||
* Legacy
|
||||
*/
|
||||
export function getElementById(id: any, element: any, recurse?: any): any;
|
||||
/***
|
||||
* Legacy
|
||||
*/
|
||||
export function getElements(options: any, element: any, recurse?: any, limit?: any): any;
|
||||
/***
|
||||
* Legacy
|
||||
*/
|
||||
export function getElementsByTagName(name: any, element: any, recurse?: any, limit?: any): any;
|
||||
/***
|
||||
* Legacy
|
||||
*/
|
||||
export function getElementsByTagType(type: any, element: any, recurse?: any, limit?: any): any;
|
||||
export function getInnerHTML(elem: DomElement, opts: any): string;
|
||||
/***
|
||||
* Returns the name property of an element
|
||||
*
|
||||
* @argument elem The element to get the name for
|
||||
*/
|
||||
export function getName(elem: DomElement): string;
|
||||
/***
|
||||
* Returns a string representing the array of DomElements
|
||||
*
|
||||
* @argument dom An array of DomElement that should be stringified
|
||||
* @argument [opts] Optional options object
|
||||
*/
|
||||
export function getOuterHTML(dom: DomElement[], opts: { decodeEntities?: boolean, xmlMode?: boolean}): string;
|
||||
export function getParent(elem: DomElement): DomElement;
|
||||
export function getSiblings(elem: DomElement): DomElement[];
|
||||
export function getText(elem: DomElement): string;
|
||||
export function hasAttrib(elem: DomElement, name: string): boolean;
|
||||
export function isTag(elem: DomElement): boolean;
|
||||
/***
|
||||
* Prepend an element before another
|
||||
*
|
||||
* @argument elem The element to append to
|
||||
* @argument prev The element be added
|
||||
*/
|
||||
export function prepend(elem: DomElement, prev: DomElement): void;
|
||||
/***
|
||||
* Remove an element from the dom
|
||||
*
|
||||
* @argument elem The element to be removed
|
||||
*/
|
||||
export function removeElement(elem: DomElement): void;
|
||||
/***
|
||||
* Given an array of nodes, remove any member that is contained by another.
|
||||
*/
|
||||
export function removeSubsets(nodes: DomElement[]): DomElement[];
|
||||
/***
|
||||
* Replace an element in the dom
|
||||
*
|
||||
* @argument elem The element to be replaced
|
||||
* @argument replacement The element to be added
|
||||
*/
|
||||
export function replaceElement(elem: DomElement, replacement: DomElement): void;
|
||||
/***
|
||||
* Legacy
|
||||
*/
|
||||
export function testElement(options: any, element: any): any;
|
||||
/***
|
||||
* Sort an array of nodes based on their relative position in the document and
|
||||
* remove any duplicate nodes. If the array contains nodes that do not belong
|
||||
* to the same document, sort order is unspecified.
|
||||
*
|
||||
* @argument nodes Array of DOM nodes
|
||||
* @returns collection of unique nodes, sorted in document order
|
||||
*/
|
||||
export function uniqueSort(nodes: DomElement[]): DomElement[];
|
||||
23
types/domutils/tsconfig.json
Normal file
23
types/domutils/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"domutils-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/domutils/tslint.json
Normal file
1
types/domutils/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user