mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 23:37:04 +00:00
Support SVG elements; Remove extraneous definition
This commit is contained in:
@@ -59,14 +59,25 @@ h2.cleanup()
|
||||
|
||||
/* Polymorphic type tests */
|
||||
|
||||
// determine proper HTMLElement type from tagName
|
||||
let test1: HTMLCanvasElement = h('canvas');
|
||||
// fall back to Element when in doubt
|
||||
let fallbackTest = h('canvas#test3');
|
||||
|
||||
// determine proper Element type from tagName
|
||||
let htmlTest1: HTMLCanvasElement = h('canvas');
|
||||
|
||||
// allow coercion of decorated tagName to proper type
|
||||
let test2: HTMLCanvasElement = h<HTMLCanvasElement>('canvas#test2');
|
||||
let htmlTest2: HTMLCanvasElement = h<HTMLCanvasElement>('canvas#test2');
|
||||
|
||||
// if you need it to be an HTMLElement, you must coerce
|
||||
let htmlTest3 = h<HTMLElement>('canvas#test3');
|
||||
|
||||
// support SVG elements
|
||||
let svgTest1 = h('svg');
|
||||
|
||||
// allow coercions on SVG elements
|
||||
let svgTest2 = h<SVGSVGElement>('svg#test5');
|
||||
|
||||
// inline coercion if you were feeling pedantic
|
||||
// example
|
||||
h<HTMLDivElement>('div#page',
|
||||
h<HTMLDivElement>('div#header',
|
||||
h<HTMLHeadingElement>('h1.classy', 'h', { style: {'background-color': '#22f'} })));
|
||||
Vendored
+4
-7
@@ -1,18 +1,15 @@
|
||||
// Type definitions for hyperscript
|
||||
// Project: https://github.com/dominictarr/hyperscript
|
||||
// Definitions by: Mike Linkovich <https://github.com/spacejack>
|
||||
// Definitions by: Mike Linkovich <https://github.com/spacejack>, Justin Firth <https://github.com/jmfirth/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
declare module 'hyperscript' {
|
||||
|
||||
interface HyperScript {
|
||||
/** Creates a typed HTMLElement */
|
||||
<T extends keyof HTMLElementTagNameMap>(tagName: T, attrs?: Object, ...children: any[]): HTMLElementTagNameMap[T];
|
||||
/** Creates a typed HTMLElement via coercion */
|
||||
<T extends HTMLElement>(tagName: string, attrs?: Object, ...children: any[]): T;
|
||||
/** Creates an HTMLElement */
|
||||
<T extends string>(tagName: T, attrs?: Object, ...children: any[]): HTMLElement;
|
||||
/** Creates an Element */
|
||||
<T extends keyof ElementTagNameMap>(tagName: T, attrs?: Object, ...children: any[]): ElementTagNameMap[T];
|
||||
<T extends Element>(tagName: string, attrs?: Object, ...children: any[]): T;
|
||||
/** Cleans up any event handlers created by this hyperscript context */
|
||||
cleanup(): void;
|
||||
/** Creates a new hyperscript context */
|
||||
|
||||
Reference in New Issue
Block a user