Created
January 14, 2016 21:02
-
-
Save AprilArcus/b081520da9bf5be23545 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* @flow */ | |
declare class SVGElement extends Element {} | |
declare class HTMLParagraphElement extends HTMLElement { | |
align: string; | |
} | |
type ElementRegistrationOptions<T> = { | |
prototype?: { | |
createdCallback?: () => void; | |
attachedCallback?: () => void; | |
detachedCallback?: () => void; | |
attributeChangedCallback?: ( | |
attributeLocalName: string, | |
oldAttributeValue: ?string, | |
newAttributeValue: ?string, | |
attributeNamespace: ?string | |
) => void; | |
}; | |
extends?: string; | |
} | |
declare class Document extends Node { | |
registerElement<T: HTMLElement|SVGElement>( | |
type: string, | |
options?: ElementRegistrationOptions<T> | |
): Class<T>; | |
} | |
declare var document: Document; | |
export const injectCallbacks = ({ | |
createdCallback, | |
attachedCallback, | |
detachedCallback, | |
attributeChangedCallback | |
}: { | |
createdCallback: () => void, | |
attachedCallback: () => void, | |
detachedCallback: () => void, | |
attributeChangedCallback: ( | |
attributeLocalName: string, | |
oldAttributeValue: ?string, | |
newAttributeValue: ?string, | |
attributeNamespace: ?string | |
) => void | |
}): Class<HTMLParagraphElement> => document.registerElement( | |
'jus-ti-fied', { | |
extends: 'p', | |
prototype: Object.create( | |
HTMLParagraphElement.prototype, { | |
createdCallback: { value: createdCallback }, | |
attachedCallback: { value: attachedCallback }, | |
detachedCallback: { value: detachedCallback }, | |
attributeChangedCallback: { value: attributeChangedCallback } | |
} | |
) | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment