Home Manual Reference Source Test

Function

Static Public Summary
public

$(selector: string, context: Element | Document | DocumentFragment): Element[]

jQuery-like selector

public

$up(selector: string, context: Node): Element

public

Iteratable decorator for Class, Method or Getter

public

at(selector: String): Function

public

blobFrom(URI: String): Blob

public

blobOf(URI: String): Promise<Blob>

public

Decorator for Property getter which returns Data URI

public
public

classNameOf(object: *): string

public

Register a component

public
public

decoratorOf(target: Function | Object, key: String, value: Function | Object | *, descriptor: Object): DecoratorDescriptor

public

delay(second: number): Promise

public

delegate(selector: string, handler: DOMEventHandler): Function

DOM event delegate

public
public

extend(target: Object, source: ...Object): Object

Merge own properties of two or more objects together into the first object by their descriptor

public

async fileTypeOf(URI: String): Object

public

getPropertyDescriptor(object: *, key: string): Object

public

indexOf(element: Element): number

public

inputOf(element: HTMLElement, handler: function(event: Event, input: String): void)

public

isHTML(DOM: *): Boolean

public

isXDomain(URI: string | URL): boolean

public

likeArray(object: *): Boolean

public

Decorator for attributeChangedCallback() method

public

Decorator for observedAttributes getter

public

* mapTree(node: Object, fork_key: String)

Traverse Object-tree

public

mediaReady(context: Element | Document): Promise

public

multipleMap(list: Iterable, filter: function(item: *, index: number, list: Iterable): *): Array

Equivalent to the integration of Array's map() & filter() methods

public
public

on(type: String, selector: String): Function

public
public
public

readAs(file: File, type: String, encoding: String): String | ArrayBuffer

public

async request(URI: string, method: string, body: string | Object | Element, headers: Object, option: Object): string | Object | DocumentFragment | Blob

HTTP request

public

serialize(form: Element): String | FormData | Object

public
public

stringifyDOM(fragment: Node): string

public
public

toIterable(arrayLike: Object): Iterable

public

trigger(element: Element, event: String | Event, detail: *, bubbles: Boolean, cancelable: Boolean, composed: Boolean): Boolean

public

unique(list: Array, condition: String | Symbol | UniqueComparer): Array

public

watchAttributes(element: Element, names: string[], callback: AttributeWatcher): MutationObserver

Static Public

public $(selector: string, context: Element | Document | DocumentFragment): Element[] source

jQuery-like selector

Params:

NameTypeAttributeDescription
selector string
context Element | Document | DocumentFragment
  • optional
  • default: document

Return:

Element[]

Test:

public $up(selector: string, context: Node): Element source

import {$up} from 'web-cell/source/utility/DOM.js'

Params:

NameTypeAttributeDescription
selector string

CSS selector

context Node

Return:

Element (nullable: true)

Matched parent

Test:

public arrayLike(meta: DecoratorDescriptor) source

import {arrayLike} from 'web-cell/source/utility/object.js'

Iteratable decorator for Class, Method or Getter

Params:

NameTypeAttributeDescription
meta DecoratorDescriptor

Test:

public at(selector: String): Function source

import {at} from 'web-cell/source/WebCell.js'

Params:

NameTypeAttributeDescription
selector String

CSS selector

Return:

Function

Decorator for Event handler

public blobFrom(URI: String): Blob source

import {blobFrom} from 'web-cell/source/utility/resource.js'

Params:

NameTypeAttributeDescription
URI String

Data URI

Return:

Blob

Test:

public blobOf(URI: String): Promise<Blob> source

Params:

NameTypeAttributeDescription
URI String

Returned by URL.createObjectURL()

Return:

Promise<Blob>

public blobURI(meta: DecoratorDescriptor) source

import {blobURI} from 'web-cell/source/WebCell.js'

Decorator for Property getter which returns Data URI

Params:

NameTypeAttributeDescription
meta DecoratorDescriptor

public byteLength(raw: String): Number source

import {byteLength} from 'web-cell/source/utility/resource.js'

Params:

NameTypeAttributeDescription
raw String

Return:

Number

Length in Half-width characters

public classNameOf(object: *): string source

import {classNameOf} from 'web-cell/source/utility/object.js'

Params:

NameTypeAttributeDescription
object *

Return:

string

public component(meta: Object): function(elements: DecoratorDescriptor[]): Object source

import {component} from 'web-cell/source/WebCell.js'

Register a component

Params:

NameTypeAttributeDescription
meta Object
meta.template String | Node
  • optional

HTML template source or sub DOM tree

meta.style String | Element
  • optional

CSS source or <style />

meta.data Object
  • optional

Initial data

meta.tagName String
  • optional

Name of an HTML original tag to extend

Return:

function(elements: DecoratorDescriptor[]): Object

Component class decorator

Test:

public decodeMarkup(source: String): String source

import {decodeMarkup} from 'web-cell/source/utility/DOM.js'

Params:

NameTypeAttributeDescription
source String

Return:

String

Markup entries are tranformed back to Special characters or Escape Markup tags

public decoratorOf(target: Function | Object, key: String, value: Function | Object | *, descriptor: Object): DecoratorDescriptor source

import {decoratorOf} from 'web-cell/source/utility/object.js'

Params:

NameTypeAttributeDescription
target Function | Object

Class or its prototype

key String

Member name

value Function | Object | *

{ set, get } for Field accessors

descriptor Object
  • optional
  • default: {enumerable: true}

Use for Object.defineProperty()

Test:

public delay(second: number): Promise source

import {delay} from 'web-cell/source/utility/DOM.js'

Params:

NameTypeAttributeDescription
second number
  • optional
  • default: 0

Return:

Promise

Wait seconds in Macro tasks

Test:

public delegate(selector: string, handler: DOMEventHandler): Function source

import {delegate} from 'web-cell/source/utility/DOM.js'

DOM event delegate

Params:

NameTypeAttributeDescription
selector string
handler DOMEventHandler

Return:

Function

Handler wrapper

Test:

public encodeMarkup(source: String): String source

import {encodeMarkup} from 'web-cell/source/utility/DOM.js'

Params:

NameTypeAttributeDescription
source String

Markup source code

Return:

String

Special characters are tranformed to Markup entries

public extend(target: Object, source: ...Object): Object source

import {extend} from 'web-cell/source/utility/object.js'

Merge own properties of two or more objects together into the first object by their descriptor

Params:

NameTypeAttributeDescription
target Object

An object that will receive the new properties if source are passed in

source ...Object

Additional objects containing properties to merge in (Value of null or undefined will be skipped)

Return:

Object

The target parameter

Test:

See:

public async fileTypeOf(URI: String): Object source

import {fileTypeOf} from 'web-cell/source/utility/resource.js'

Params:

NameTypeAttributeDescription
URI String

HTTP(S) URL, Data URI or Object URL

Return:

Object

Return Properties:

NameTypeAttributeDescription
schema String

URI schema (http, https, data or blob)

type String

File type (same as the Extension name of a file)

Test:

public getPropertyDescriptor(object: *, key: string): Object source

import {getPropertyDescriptor} from 'web-cell/source/utility/object.js'

Params:

NameTypeAttributeDescription
object *
key string

Property name

Test:

public indexOf(element: Element): number source

import {indexOf} from 'web-cell/source/utility/DOM.js'

Params:

NameTypeAttributeDescription
element Element

Return:

number

The index of element in its siblings

Test:

public inputOf(element: HTMLElement, handler: function(event: Event, input: String): void) source

import {inputOf} from 'web-cell/source/utility/DOM.js'

Params:

NameTypeAttributeDescription
element HTMLElement
handler function(event: Event, input: String): void

public isHTML(DOM: *): Boolean source

import {isHTML} from 'web-cell/source/utility/DOM.js'

Params:

NameTypeAttributeDescription
DOM *

Return:

Boolean

public isXDomain(URI: string | URL): boolean source

import {isXDomain} from 'web-cell/source/utility/resource.js'

Params:

NameTypeAttributeDescription
URI string | URL

Full URL of a resource

Return:

boolean

Whether it's cross domain to current page

public likeArray(object: *): Boolean source

import {likeArray} from 'web-cell/source/utility/object.js'

Params:

NameTypeAttributeDescription
object *

Return:

Boolean

Test:

public mapData(meta: DecoratorDescriptor) source

import {mapData} from 'web-cell/source/WebCell.js'

Decorator for attributeChangedCallback() method

Params:

NameTypeAttributeDescription
meta DecoratorDescriptor

Test:

public mapProperty(meta: DecoratorDescriptor) source

import {mapProperty} from 'web-cell/source/WebCell.js'

Decorator for observedAttributes getter

Params:

NameTypeAttributeDescription
meta DecoratorDescriptor

Test:

public * mapTree(node: Object, fork_key: String) source

import {mapTree} from 'web-cell/source/utility/object.js'

Traverse Object-tree

Params:

NameTypeAttributeDescription
node Object

Object tree

fork_key String

Key of children list

Test:

public mediaReady(context: Element | Document): Promise source

import {mediaReady} from 'web-cell/source/utility/DOM.js'

Params:

NameTypeAttributeDescription
context Element | Document
  • optional

Return:

Promise

Resolved when all media elements in context are loaded

public multipleMap(list: Iterable, filter: function(item: *, index: number, list: Iterable): *): Array source

import {multipleMap} from 'web-cell/source/utility/object.js'

Equivalent to the integration of Array's map() & filter() methods

Params:

NameTypeAttributeDescription
list Iterable
filter function(item: *, index: number, list: Iterable): *

Return item itself to reserve, undefined or null to ignore, or Array to merge in.

Return:

Array

Test:

See:

public nextTick(): Promise<number> source

import {nextTick} from 'web-cell/source/utility/DOM.js'

Test:

public on(type: String, selector: String): Function source

import {on} from 'web-cell/source/WebCell.js'

Params:

NameTypeAttributeDescription
type String
selector String

Return:

Function

Decorator for Event handler

public parse(raw: String): Object source

Params:

NameTypeAttributeDescription
raw String

JSON source code

Return:

Object

Test:

public parseDOM(markup: string): DocumentFragment source

import {parseDOM} from 'web-cell/source/utility/DOM.js'

Params:

NameTypeAttributeDescription
markup string

Code of an markup fragment

Test:

public readAs(file: File, type: String, encoding: String): String | ArrayBuffer source

Params:

NameTypeAttributeDescription
file File
type String
  • optional
  • default: 'DataURL'

https://developer.mozilla.org/en-US/docs/Web/API/FileReader#Methods

encoding String
  • optional
  • default: 'UTF-8'

https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsText#Parameters

Return:

String | ArrayBuffer

public async request(URI: string, method: string, body: string | Object | Element, headers: Object, option: Object): string | Object | DocumentFragment | Blob source

import {request} from 'web-cell/source/utility/resource.js'

HTTP request

Params:

NameTypeAttributeDescription
URI string

HTTP URL

method string
  • optional
  • default: 'GET'
body string | Object | Element
  • optional

Data to send

headers Object
  • optional
option Object
  • optional

https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters

Return:

string | Object | DocumentFragment | Blob

Parse response data automatically

Test:

public serialize(form: Element): String | FormData | Object source

import {serialize} from 'web-cell/source/utility/resource.js'

Params:

NameTypeAttributeDescription
form Element

<form /> or <fieldset />

Return:

String | FormData | Object

Test:

public stringify(data: Object): String source

import {stringify} from 'web-cell/source/utility/resource.js'

Params:

NameTypeAttributeDescription
data Object

Return:

String

JSON source code

Test:

public stringifyDOM(fragment: Node): string source

import {stringifyDOM} from 'web-cell/source/utility/DOM.js'

Params:

NameTypeAttributeDescription
fragment Node

Return:

string

HTML/XML source code

Test:

public targetOf(event: Event): Element source

import {targetOf} from 'web-cell/source/utility/DOM.js'

Params:

NameTypeAttributeDescription
event Event

Return:

Element

The target of event object (Shadow DOM is in account)

Test:

public toIterable(arrayLike: Object): Iterable source

import {toIterable} from 'web-cell/source/utility/object.js'

Params:

NameTypeAttributeDescription
arrayLike Object

Return:

Iterable

arrayLike

public trigger(element: Element, event: String | Event, detail: *, bubbles: Boolean, cancelable: Boolean, composed: Boolean): Boolean source

import {trigger} from 'web-cell/source/utility/DOM.js'

Params:

NameTypeAttributeDescription
element Element
event String | Event
detail *
  • nullable: true

Additional data

bubbles Boolean
  • nullable: true
cancelable Boolean
  • nullable: true
composed Boolean
  • nullable: true

Whether the event will cross from the shadow DOM into the standard DOM after reaching the shadow root

Return:

Boolean

Event be canceled or not

public unique(list: Array, condition: String | Symbol | UniqueComparer): Array source

import {unique} from 'web-cell/source/utility/object.js'

Params:

NameTypeAttributeDescription
list Array

Original array

condition String | Symbol | UniqueComparer
  • optional

Return:

Array

Deduplicated new array

Test:

public watchAttributes(element: Element, names: string[], callback: AttributeWatcher): MutationObserver source

import {watchAttributes} from 'web-cell/source/utility/DOM.js'

Params:

NameTypeAttributeDescription
element Element
names string[]
callback AttributeWatcher

Return:

MutationObserver

Test: