MCPcopy Create free account
hub / github.com/cyclejs/cyclejs / BodyDOMSource

Class BodyDOMSource

dom/src/BodyDOMSource.ts:7–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5import {fromEvent} from './fromEvent';
6
7export class BodyDOMSource implements DOMSource {
8 constructor(private _name: string) {
9 }
10
11 public select(selector: string): DOMSource {
12 // This functionality is still undefined/undecided.
13 return this;
14 }
15
16 public elements(): MemoryStream<HTMLBodyElement> {
17 const out: DevToolEnabledSource & MemoryStream<HTMLBodyElement> =
18 adapt(xs.of(document.body));
19 out._isCycleSource = this._name;
20 return out;
21 }
22
23 public events(eventType: string, options: EventsFnOptions = {}): Stream<Event> {
24 let stream: Stream<Event>;
25 if (options && typeof options.useCapture === 'boolean') {
26 stream = fromEvent(document.body, eventType, options.useCapture);
27 } else {
28 stream = fromEvent(document.body, eventType);
29 }
30 const out: DevToolEnabledSource & Stream<Event> = adapt(stream);
31 out._isCycleSource = this._name;
32 return out;
33 }
34}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected