aurelia-pal-nodejs
Advanced tools
Comparing version 1.0.0-beta.3.2.0 to 1.0.0-beta.3.3.0
@@ -31,3 +31,3 @@ /** | ||
*/ | ||
addEventListener(eventName: string, callback: EventListener, capture: boolean): void; | ||
addEventListener(eventName: string, callback: EventListenerOrEventListenerObject, capture: boolean): void; | ||
/** | ||
@@ -39,3 +39,3 @@ * Remove an event listener from the document. | ||
*/ | ||
removeEventListener(eventName: string, callback: EventListener, capture: boolean): void; | ||
removeEventListener(eventName: string, callback: EventListenerOrEventListenerObject, capture: boolean): void; | ||
/** | ||
@@ -52,3 +52,4 @@ * Adopts a node from an external document. | ||
*/ | ||
createElement(tagName: string): Element; | ||
createElement<T extends keyof HTMLElementTagNameMap>(tagName: T): HTMLElementTagNameMap[T]; | ||
createElement(tagName: string): HTMLElement; | ||
/** | ||
@@ -108,2 +109,8 @@ * Creates the specified HTML attribute | ||
/** | ||
* Performs a query selector on the document and returns first matched element, depth first. | ||
* @param query The query to use in searching the document. | ||
* @return A list of all matched elements in the document. | ||
*/ | ||
querySelector<E extends Element = Element>(selectors: string): E | null; | ||
/** | ||
* Performs a query selector on the document and returns all located matches. | ||
@@ -113,3 +120,3 @@ * @param query The query to use in searching the document. | ||
*/ | ||
querySelectorAll(query: string): NodeList; | ||
querySelectorAll<E extends Element = Element>(selectors: string): NodeListOf<E>; | ||
/** | ||
@@ -126,3 +133,3 @@ * Gets the element that is the next sibling of the provided element. | ||
*/ | ||
createTemplateFromMarkup(markup: string): Element; | ||
createTemplateFromMarkup(markup: string): HTMLTemplateElement; | ||
/** | ||
@@ -129,0 +136,0 @@ * Appends a node to the parent, if provided, or the document.body otherwise. |
import { IDom } from './dom'; | ||
import { IGlobal } from './global'; | ||
declare module './global' { | ||
interface IGlobal { | ||
window: any; | ||
document: any; | ||
} | ||
} | ||
/** | ||
@@ -15,5 +21,5 @@ * Represents the core APIs of the DOM. | ||
activeElement: Element; | ||
addEventListener(eventName: string, callback: EventListener, capture: boolean): void; | ||
removeEventListener(eventName: string, callback: EventListener, capture: boolean): void; | ||
createElement(tagName: string): Element; | ||
addEventListener(eventName: string, callback: EventListenerOrEventListenerObject, capture: boolean): void; | ||
removeEventListener(eventName: string, callback: EventListenerOrEventListenerObject, capture: boolean): void; | ||
createElement<T extends keyof HTMLElementTagNameMap>(tagName: T): HTMLElementTagNameMap[T]; | ||
createAttribute(name: string): Attr; | ||
@@ -25,9 +31,10 @@ createTextNode(text: string): Text; | ||
createMutationObserver(callback: (changes: MutationRecord[], instance: MutationObserver) => void): MutationObserver; | ||
createCustomEvent(eventType: string, options: Object): CustomEvent; | ||
createCustomEvent(eventType: string, options?: Object): CustomEvent; | ||
dispatchEvent(evt: Event): void; | ||
getComputedStyle(element: Element): CSSStyleDeclaration; | ||
getElementById(id: string): Element; | ||
querySelectorAll(query: string): NodeList; | ||
querySelector<E extends Element = Element>(query: string): E | null; | ||
querySelectorAll<E extends Element = Element>(query: string): NodeListOf<E>; | ||
nextElementSibling(element: Element): Element; | ||
createTemplateFromMarkup(markup: string): Element; | ||
createTemplateFromMarkup(markup: string): HTMLTemplateElement; | ||
injectStyles(styles: string, destination?: Element, prepend?: boolean): Node; | ||
@@ -34,0 +41,0 @@ adoptNode(node: Node): Node; |
@@ -56,2 +56,5 @@ "use strict"; | ||
} | ||
querySelector(query) { | ||
return this.global.document.querySelector(query); | ||
} | ||
querySelectorAll(query) { | ||
@@ -58,0 +61,0 @@ return this.global.document.querySelectorAll(query); |
@@ -5,2 +5,11 @@ import { IPlatform } from './platform'; | ||
import { JSDOM } from 'jsdom'; | ||
declare module './global' { | ||
interface IGlobal { | ||
performance: any; | ||
location: any; | ||
history: any; | ||
addEventListener(eventName: string, callback: EventListenerOrEventListenerObject, capture?: boolean): void; | ||
removeEventListener(eventName: string, callback: EventListenerOrEventListenerObject, capture?: boolean): void; | ||
} | ||
} | ||
export declare class NodeJsPlatform implements IPlatform { | ||
@@ -43,3 +52,3 @@ global: IGlobal; | ||
*/ | ||
addEventListener(eventName: string, callback: Function, capture?: boolean): void; | ||
addEventListener(eventName: string, callback: EventListenerOrEventListenerObject, capture?: boolean): void; | ||
/** | ||
@@ -51,3 +60,3 @@ * Remove a global event listener. | ||
*/ | ||
removeEventListener(eventName: string, callback: Function, capture?: boolean): void; | ||
removeEventListener(eventName: string, callback: EventListenerOrEventListenerObject, capture?: boolean): void; | ||
/** | ||
@@ -54,0 +63,0 @@ * The runtime's XMLHttpRequest API. |
@@ -43,3 +43,3 @@ import { IPerformance } from './performance'; | ||
*/ | ||
addEventListener(eventName: string, callback: Function, capture?: boolean): void; | ||
addEventListener(eventName: string, callback: EventListenerOrEventListenerObject, capture?: boolean): void; | ||
/** | ||
@@ -51,3 +51,3 @@ * Remove a global event listener. | ||
*/ | ||
removeEventListener(eventName: string, callback: Function, capture?: boolean): void; | ||
removeEventListener(eventName: string, callback: EventListenerOrEventListenerObject, capture?: boolean): void; | ||
/** | ||
@@ -54,0 +54,0 @@ * The runtime's XMLHttpRequest API. |
@@ -71,7 +71,7 @@ "use strict"; | ||
} | ||
catch (e) { | ||
catch (e) { // ie <8 will throw if you set an unknown property on a text node | ||
try { | ||
return $ele.nodeValue; // naive | ||
} | ||
catch (shitie) { | ||
catch (shitie) { // when text node is removed: https://gist.github.com/megawac/8355978 :( | ||
return this.counter++; | ||
@@ -113,3 +113,3 @@ } | ||
static indexOf(set, item, idx, prop) { | ||
for (; idx < set.length; idx++) { | ||
for ( /*idx = ~~idx*/; idx < set.length; idx++) { // start idx is always given as this is internal | ||
if ((prop ? set[idx][prop] : set[idx]) === item) | ||
@@ -235,3 +235,3 @@ return idx; | ||
let mutations = observer.takeRecords(); | ||
if (mutations.length) { | ||
if (mutations.length) { // fire away | ||
// calling the listener with context is not spec but currently consistent with FF and WebKit | ||
@@ -325,5 +325,5 @@ observer._listener(mutations, observer); | ||
$old = oldstruct && oldstruct.node; | ||
if ($cur === $old) { | ||
if ($cur === $old) { // expected case - optimized for this case | ||
// check attributes as specified by config | ||
if (config.attr && oldstruct.attr) { | ||
if (config.attr && oldstruct.attr) { /* oldstruct.attr instead of textnode check */ | ||
this.findAttributeMutations(mutations, $cur, oldstruct.attr, config.afilter); | ||
@@ -347,5 +347,5 @@ } | ||
} | ||
else { | ||
else { // (uncommon case) lookahead until they are the same again or the end of children | ||
dirty = true; | ||
if (!map) { | ||
if (!map) { // delayed initalization (big perf benefit) | ||
map = {}; | ||
@@ -356,3 +356,3 @@ conflicts = []; | ||
// check id is in the location map otherwise do a indexOf search | ||
if (!(map[id = Util.getElementId($cur)])) { | ||
if (!(map[id = Util.getElementId($cur)])) { // to prevent double checking | ||
// mark id as found | ||
@@ -359,0 +359,0 @@ map[id] = true; |
{ | ||
"name": "aurelia-pal-nodejs", | ||
"version": "1.0.0-beta.3.2.0", | ||
"version": "1.0.0-beta.3.3.0", | ||
"description": "The Node.js-specific implementation of Aurelia's platform abstraction layer.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
65154
1521
31