bigpipe-util 0.2.12 → 0.2.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = onAfterLoad;
7
+ var _EventListener = _interopRequireDefault(require("fbjs/lib/EventListener"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ function onAfterLoad(callback) {
10
+ if (document.readyState === 'complete') {
11
+ setTimeout(callback, 0);
12
+ } else {
13
+ const event = _EventListener.default.capture(window, 'load', () => {
14
+ event.remove();
15
+ callback();
16
+ });
17
+ }
18
+ }
@@ -1,27 +1,32 @@
1
- import $ from './$';
2
-
3
- export default function replaceTransportMarkers(markerValue, markers, key) {
4
- const marker = typeof key !== "undefined" ? markers[key] : markers;
5
-
6
- if (Array.isArray(marker)) {
7
- for (let i = 0; i < marker.length; i++) {
8
- replaceTransportMarkers(markerValue, marker, i);
9
- }
10
- } else {
11
- if (marker && typeof marker == "object") {
12
- if (marker.__m) {
13
- markers[key] = window.require(marker.__m);
14
- } else if (marker.__e) {
15
- markers[key] = $(marker.__e);
16
- } else if (marker.__map) {
17
- markers[key] = new Map(marker.__map);
18
- } else if (marker.__set) {
19
- markers[key] = new Set(marker.__set);
20
- } else {
21
- for (const value in marker) {
22
- replaceTransportMarkers(markerValue, marker, value);
23
- }
24
- }
25
- }
26
- }
27
- }
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = replaceTransportMarkers;
7
+ var _$ = _interopRequireDefault(require("./$"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ function replaceTransportMarkers(markerValue, markers, key) {
10
+ const marker = typeof key !== 'undefined' ? markers[key] : markers;
11
+ if (Array.isArray(marker)) {
12
+ for (let i = 0; i < marker.length; i++) {
13
+ replaceTransportMarkers(markerValue, marker, i);
14
+ }
15
+ } else {
16
+ if (marker && typeof marker == 'object') {
17
+ if (marker.__m) {
18
+ markers[key] = window.require(marker.__m);
19
+ } else if (marker.__e) {
20
+ markers[key] = (0, _$.default)(marker.__e);
21
+ } else if (marker.__map) {
22
+ markers[key] = new Map(marker.__map);
23
+ } else if (marker.__set) {
24
+ markers[key] = new Set(marker.__set);
25
+ } else {
26
+ for (const value in marker) {
27
+ replaceTransportMarkers(markerValue, marker, value);
28
+ }
29
+ }
30
+ }
31
+ }
32
+ }
@@ -1,57 +1,46 @@
1
- import onAfterLoad from "./onAfterLoad";
2
-
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = waitForLoad;
7
+ var _onAfterLoad = _interopRequireDefault(require("./onAfterLoad"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
3
9
  let loadingCounter = 0;
4
10
  let originalCursor = '';
5
-
6
- export default function waitForLoad(elementOnClicked, event, callback = () => {
7
- }) {
11
+ function waitForLoad(elementOnClicked, event, callback = () => {}) {
8
12
  const boundCallback = callback.bind(elementOnClicked, event);
9
13
  const body = document.body;
10
-
11
14
  if (document.readyState === 'complete') {
12
15
  return boundCallback();
13
16
  }
14
-
15
17
  const type = (event || window.event).type;
16
18
  loadingCounter++;
17
-
18
19
  if (loadingCounter === 1) {
19
20
  originalCursor = body.style.cursor;
20
21
  body.style.cursor = 'progress';
21
22
  }
22
-
23
23
  switch (type) {
24
24
  case 'load':
25
25
  case 'focus':
26
- onAfterLoad(boundCallback);
26
+ (0, _onAfterLoad.default)(boundCallback);
27
27
  return;
28
-
29
28
  case 'click':
30
29
  elementOnClicked.style.cursor = 'progress';
31
-
32
- onAfterLoad(() => {
30
+ (0, _onAfterLoad.default)(() => {
33
31
  loadingCounter--;
34
-
35
32
  if (loadingCounter === 0) {
36
33
  body.style.cursor = originalCursor;
37
34
  }
38
-
39
35
  elementOnClicked.style.cursor = '';
40
-
41
36
  const result = boundCallback();
42
37
  const href = elementOnClicked.getAttribute('href');
43
-
44
- if (
45
- elementOnClicked.tagName.toLowerCase() === 'a' &&
46
- result !== false &&
47
- href
48
- ) {
38
+ if (elementOnClicked.tagName.toLowerCase() === 'a' && result !== false && href) {
49
39
  window.location.href = href;
50
40
  } else {
51
41
  elementOnClicked.click();
52
42
  }
53
43
  });
54
44
  }
55
-
56
45
  return false;
57
- }
46
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bigpipe-util",
3
3
  "description": "This library currently implements small part of Facebook BigPipe so far, but the advantage is to efficiently insert/replace content and work with the DOM. It is also possible to easily call JavaScript modules from PHP.",
4
- "version": "0.2.12",
4
+ "version": "0.2.14",
5
5
  "keywords": [
6
6
  "bigpipe",
7
7
  "xhr",
@@ -16,10 +16,29 @@
16
16
  "type": "git",
17
17
  "url": "git://github.com/richardDobron/bigpipe-util.git"
18
18
  },
19
- "bugs:": "https://github.com/richardDobron/bigpipe-util/issues",
19
+ "bugs": {
20
+ "url": "https://github.com/richardDobron/bigpipe-util/issues"
21
+ },
20
22
  "license": "MIT",
23
+ "files": [
24
+ "dist"
25
+ ],
21
26
  "dependencies": {
22
27
  "fbjs": "^3.0.4",
23
28
  "modal-vanilla": "^0.9.0"
29
+ },
30
+ "scripts": {
31
+ "build": "babel src --out-dir dist",
32
+ "lint": "eslint src",
33
+ "format": "prettier --write \"src/**/*.js\"",
34
+ "format:check": "prettier --check \"src/**/*.js\""
35
+ },
36
+ "devDependencies": {
37
+ "@babel/cli": "^7.24.0",
38
+ "@babel/core": "^7.24.0",
39
+ "@babel/preset-env": "^7.24.0",
40
+ "eslint": "^8.57.0",
41
+ "eslint-config-prettier": "^10.1.0",
42
+ "prettier": "^3.9.0"
24
43
  }
25
44
  }
package/.editorconfig DELETED
@@ -1,9 +0,0 @@
1
- root = true
2
-
3
- [*]
4
- charset = utf-8
5
- end_of_line = lf
6
- indent_size = 2
7
- indent_style = space
8
- insert_final_newline = true
9
- trim_trailing_whitespace = true
package/CHANGELOG.md DELETED
@@ -1,105 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to `bigpipe-util` will be documented in this file.
4
-
5
- Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
6
-
7
- ## v0.2.12 - 2026-01-12
8
- ### Added
9
- - Added `Pagelet.js`, `BigPipe.js`
10
-
11
- ## v0.2.11 - 2025-12-27
12
- ### Added
13
- - Added `incrementRequests` method to AsyncRequest.js
14
- - Added submitter to form data in onSubmit handler
15
-
16
- ## v0.2.10 - 2025-05-15
17
-
18
- ### Added
19
- - Added `onAfterLoad.js`, `waitForLoad.js`
20
- - Added `timeout` to open dialog with a delay in method `showFromModel`
21
-
22
- ## v0.2.8 - 2025-05-02
23
-
24
- ### Added
25
- - Added `timeout` to open dialog with a delay in method `showFromModel`
26
-
27
- ## v0.2.7 - 2025-03-22
28
-
29
- ### Added
30
- - Added `timeout` to open dialog with a delay in method `render`
31
-
32
- ## v0.2.6 - 2025-01-16
33
-
34
- ### Added
35
- - Added `limit` parameter to `Dialog.js` for limiting the number of closed dialogs
36
-
37
- ## v0.2.5 - 2023-03-07
38
-
39
- ### Added
40
- - Added `Arbiter.js` event system
41
- - Added methods `byClass`, `byAttribute`, `find` to `Parent.js`
42
-
43
- ### Fixed
44
- - Fixed controller calling
45
-
46
- ## v0.2.4 - 2023-02-03
47
-
48
- ### Fixed
49
- - Fixed controller calling
50
-
51
- ## v0.2.3 - 2023-02-04
52
-
53
- ### Added
54
- - Added setFinallyHandler for AsyncRequest
55
-
56
- ## v0.2.2 - 2022-08-03
57
-
58
- ### Fixed
59
- - Calls for modules without constructor
60
- - Dialog opening when using instant closing
61
-
62
- ## v0.2.1 - 2022-06-02
63
-
64
- ### Added
65
- - Prevent links from being double-clicked
66
- - Support for keyboard (close by escape)
67
-
68
- ### Fixed
69
- - Closing dialogs with [esc] in the correct order
70
-
71
- ## v0.2.0 - 2022-05-17
72
-
73
- ### Added
74
- - Shield to prevent "JSON Hijacking"
75
- - Invalid node checking for AsyncDOM
76
-
77
- ### Fixed
78
- - Backdrop for 2+ opened dialogs
79
-
80
- ## v0.1.4 - 2022-05-06
81
-
82
- ### Added
83
- - Async requests counter
84
- - Support for extra arguments in dialog controller
85
-
86
- ### Fixed
87
- - Arguments for non-method require calls
88
-
89
- ## v0.1.3 - 2022-04-27
90
-
91
- ### Added
92
- - Method to close only current dialog
93
-
94
- ### Fixed
95
- - Dialog z-index
96
-
97
- ## v0.1.2 - 2022-04-14
98
-
99
- ### Added
100
- - Dialogs support.
101
-
102
- ## v0.1.1 - 2022-03-27
103
-
104
- ### Added
105
- - Part of BigPipe implementation for Webpack.
package/bigpipe.svg DELETED
@@ -1,13 +0,0 @@
1
- <svg width="254.23999568394254" height="64.8" viewBox="0 0 254.23999568394254 64.8" xmlns="http://www.w3.org/2000/svg">
2
- <g transform="matrix(3.0856473041983374,0,0,3.0856473041983374,-6.171373325690784,-6.1698442238608315)" fill="#478be6">
3
- <g xmlns="http://www.w3.org/2000/svg">
4
- <path d="M2.2427,8.9287a.5.5,0,0,1,0-.8574l10-6a.4971.4971,0,0,1,.5146,0l10,6a.5.5,0,0,1,0,.8574l-10,6a.5.5,0,0,1-.5146,0Zm20,3.1426L12.5,17.917,2.7573,12.0713a.5.5,0,0,0-.5146.8574l10,6a.5.5,0,0,0,.5146,0l10-6a.5.5,0,0,0-.5146-.8574Zm0,4L12.5,21.917,2.7573,16.0713a.5.5,0,0,0-.5146.8574l10,6a.5.5,0,0,0,.5146,0l10-6a.5.5,0,0,0-.5146-.8574Z"></path>
5
- </g>
6
- </g>
7
- <g transform="matrix(2.500000066227385,0,0,2.500000066227385,81.99999920527138,0.49999675485814166)" fill="#478be6">
8
- <path d="M8.92 12.24 c1.48 0.4 2.88 1.72 2.88 3.66 c0 2.54 -1.6 4.1 -5.08 4.1 l-5.52 0 l0 -14 l5.22 0 c2.9 0 4.36 1.64 4.36 3.52 c0 1.48 -0.96 2.32 -1.86 2.72 z M6.14 8.56 l-2.02 0 l0 2.82 l2.02 0 c1.24 0 1.74 -0.58 1.74 -1.42 c0 -0.9 -0.58 -1.4 -1.74 -1.4 z M6.56 17.44 c1.6 0 2.32 -0.66 2.32 -1.9 c0 -1.06 -0.72 -1.8 -2.44 -1.8 l-2.32 0 l0 3.7 l2.44 0 z M16.62 6 l0 14 l-2.92 0 l0 -14 l2.92 0 z M32.2 12.559999999999999 c0.62 4.7 -2.44 7.64 -6.22 7.64 c-3.98 0 -7.26 -2.94 -7.26 -7.2 s3.36 -7.2 7.26 -7.2 c1.86 0 3.5 0.6 4.7 1.66 l-1.76 1.98 c-0.74 -0.52 -1.74 -0.9 -2.76 -0.9 c-2.54 0 -4.4 1.86 -4.4 4.46 s1.8 4.46 4.22 4.46 c1.84 0 3.12 -0.66 3.52 -2.42 l-3.3 0 l0 -2.48 l6 0 z"></path>
9
- </g>
10
- <g transform="matrix(2.5714285714285716,0,0,2.5714285714285716,166.91428559167045,-0.4285714285714306)" fill="#478be6">
11
- <path d="M5.46 6 c3.14 0 4.8 1.94 4.8 4.3 c0 2.42 -1.66 4.34 -4.8 4.34 l-3.68 0 l0 5.36 l-0.58 0 l0 -14 l4.26 0 z M5.54 14.04 c2.52 0 4.14 -1.46 4.14 -3.74 c0 -2.32 -1.62 -3.72 -4.14 -3.72 l-3.76 0 l0 7.46 l3.76 0 z M12.74 6 l0 14 l-0.58 0 l0 -14 l0.58 0 z M19.400000000000002 6 c3.14 0 4.8 1.94 4.8 4.3 c0 2.42 -1.66 4.34 -4.8 4.34 l-3.68 0 l0 5.36 l-0.58 0 l0 -14 l4.26 0 z M19.48 14.04 c2.52 0 4.14 -1.46 4.14 -3.74 c0 -2.32 -1.62 -3.72 -4.14 -3.72 l-3.76 0 l0 7.46 l3.76 0 z M26.680000000000003 19.42 l7.28 0 l0 0.58 l-7.68 0 l-0.18 0 l0 -14 l0.58 0 l7.1 0 l0 0.58 l-7.1 0 l0 6.1 l5.66 0 l0 0.58 l-5.66 0 l0 6.16 z"></path>
12
- </g>
13
- </svg>
package/src/Pagelet.js DELETED
@@ -1,131 +0,0 @@
1
- import BigPipe, { RESOURCE_PHASE } from "./BigPipe";
2
- import ServerJS from "./ServerJS";
3
- import AsyncDOM from "./async/AsyncDOM";
4
-
5
- const serverJS = new ServerJS();
6
- const asyncDOM = new AsyncDOM();
7
- const bigPipe = new BigPipe();
8
-
9
- export const PAGELET_PHASE = Object.freeze({
10
- ARRIVE_START: 0,
11
- LOADING_CSS: 1,
12
- DISPLAY_START: 2,
13
- DISPLAY_END: 3,
14
- ARRIVE_END: 4
15
- });
16
-
17
- function areAllResourcesLoaded(resources) {
18
- if (resources.size === 0) {
19
- return true;
20
- }
21
- return Array.from(resources.values()).every(
22
- resource => resource.phase === RESOURCE_PHASE.LOADED
23
- );
24
- }
25
-
26
- export default class Pagelet {
27
- cssResources = new Map();
28
-
29
- jsResources = new Map();
30
-
31
- id = "";
32
-
33
- phase = PAGELET_PHASE.ARRIVE_START;
34
-
35
- constructor(pageletData) {
36
- this.bigPipe = bigPipe;
37
- this.id = pageletData.id;
38
- this.phase = PAGELET_PHASE.ARRIVE_START;
39
- this.domops = pageletData.domops;
40
- this.jsmods = pageletData.jsmods;
41
- this.css = pageletData.css;
42
- this.js = pageletData.js;
43
- this.cssResources = new Map();
44
- this.jsResources = new Map();
45
- }
46
-
47
- isComplete() {
48
- return this.phase === PAGELET_PHASE.ARRIVE_END;
49
- }
50
-
51
- setPhase(phase) {
52
- this.phase = phase;
53
- }
54
-
55
- start() {
56
- if (this.phase !== PAGELET_PHASE.ARRIVE_START) {
57
- return;
58
- }
59
-
60
- if (this.css.length > 0) {
61
- this.css.forEach((cssFile) => {
62
- const cssResource = this.bigPipe.pageletResourceFactory(cssFile, 'css');
63
- this.attachCssResource(cssResource);
64
- });
65
- }
66
-
67
- if (this.js.length > 0) {
68
- this.js.forEach((jsFile) => {
69
- const jsResource = this.bigPipe.pageletResourceFactory(jsFile, 'js');
70
- this.attachJsResource(jsResource);
71
- });
72
- }
73
-
74
- if (this.cssResources.size > 0) {
75
- this.setPhase(PAGELET_PHASE.LOADING_CSS);
76
- this.cssResources.forEach((resource) => {
77
- resource.startLoading();
78
- });
79
- } else {
80
- this.setContent();
81
- this.onJsFinished();
82
- }
83
- }
84
-
85
- attachCssResource(resource) {
86
- resource.attachToPagelet(() => this.onCssFinished(resource));
87
- this.cssResources.set(resource.file, resource);
88
- }
89
-
90
- attachJsResource(resource) {
91
- resource.attachToPagelet(() => this.onJsFinished());
92
- this.jsResources.set(resource.file, resource);
93
- }
94
-
95
- onJsFinished() {
96
- if (this.isComplete()) {
97
- return;
98
- }
99
-
100
- if (!areAllResourcesLoaded(this.jsResources)) {
101
- return;
102
- }
103
-
104
- this.processJsMods();
105
-
106
- this.setPhase(PAGELET_PHASE.ARRIVE_END);
107
- }
108
-
109
- processJsMods() {
110
- serverJS.handle(this.jsmods);
111
- }
112
-
113
- onCssFinished() {
114
- if (!areAllResourcesLoaded(this.cssResources)) {
115
- return;
116
- }
117
-
118
- this.setContent();
119
- }
120
-
121
- setContent() {
122
- this.setPhase(PAGELET_PHASE.DISPLAY_START);
123
-
124
- if (this.domops) {
125
- asyncDOM.invoke(this.domops);
126
- }
127
-
128
- this.setPhase(PAGELET_PHASE.DISPLAY_END);
129
- this.bigPipe.pageletDisplayed(this);
130
- }
131
- }
package/src/Primer.js DELETED
@@ -1,160 +0,0 @@
1
- import AsyncRequest from "./async/AsyncRequest";
2
- import {byTag} from "./core/Parent";
3
-
4
- export default function Primer() {
5
- const rootElement = document.documentElement;
6
-
7
- const RELATIONSHIP_REGEX = /async(?:-post)?|dialog/;
8
-
9
- rootElement.onclick = function (event) {
10
- event = event || window.event;
11
- const elementOnClicked = event.target || event.srcElement;
12
-
13
- const linkNodeOnClicked = byTag(elementOnClicked, "A");
14
-
15
- if (!linkNodeOnClicked) {
16
- return;
17
- }
18
-
19
- const ajaxHref = linkNodeOnClicked.getAttribute("ajaxify")
20
- const realHref = linkNodeOnClicked.href
21
- let relationship = linkNodeOnClicked.rel && linkNodeOnClicked.rel.match(RELATIONSHIP_REGEX);
22
- relationship = relationship && relationship[0];
23
-
24
- if (ajaxHref && realHref && !/#$/.test(realHref)) {
25
- const isMiddleMouseButton = event.which && event.which === 2;
26
- const hasModifierKey = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
27
-
28
- if (isMiddleMouseButton || hasModifierKey) {
29
- return;
30
- }
31
- }
32
-
33
- if (linkNodeOnClicked.classList.contains('async-saving')) {
34
- event.preventDefault();
35
- return;
36
- }
37
-
38
- switch (relationship) {
39
- case "async":
40
- case "async-post":
41
- event.preventDefault();
42
-
43
- (new AsyncRequest(ajaxHref))
44
- .setRelative(linkNodeOnClicked)
45
- .setInitialHandler(() => {
46
- linkNodeOnClicked.classList.add("async-saving");
47
- })
48
- .setHandler(() => {
49
- linkNodeOnClicked.classList.remove("async-saving");
50
- })
51
- .setErrorHandler(() => {
52
- linkNodeOnClicked.classList.remove("async-saving");
53
- })
54
- .setMethod(relationship === "async-post" ? "POST" : "GET")
55
- .send();
56
- break;
57
- case "dialog":
58
- event.preventDefault();
59
-
60
- (new AsyncRequest(linkNodeOnClicked.getAttribute("ajaxify")))
61
- .setRelative(linkNodeOnClicked)
62
- .setInitialHandler(() => {
63
- linkNodeOnClicked.classList.add("async-saving");
64
- })
65
- .setHandler(() => {
66
- linkNodeOnClicked.classList.remove("async-saving");
67
- })
68
- .setErrorHandler(() => {
69
- linkNodeOnClicked.classList.remove("async-saving");
70
- })
71
- .setMethod("POST")
72
- .send();
73
- break;
74
- }
75
- };
76
-
77
- rootElement.onsubmit = function (event) {
78
- event = event || window.event;
79
- const eventTarget = event.target || event.srcElement;
80
-
81
- if (eventTarget &&
82
- eventTarget.nodeName === "FORM" &&
83
- eventTarget.getAttribute("rel") === "async") {
84
- event.preventDefault();
85
-
86
- const formData = new FormData(eventTarget);
87
- const submitter = event.submitter || eventTarget.querySelector("button[type='submit']");
88
- const activeControls = eventTarget.querySelectorAll("input:not([readonly]),select:not([readonly]),textarea:not([readonly])");
89
-
90
- if (submitter.name) {
91
- formData.append(submitter.name, submitter.value);
92
- }
93
-
94
- (new AsyncRequest(eventTarget.getAttribute("ajaxify") || eventTarget.getAttribute("action")))
95
- .setMethod(eventTarget.method || "POST")
96
- .setRelative(eventTarget)
97
- .setData(formData)
98
- .setInitialHandler(function () {
99
- eventTarget.classList.add("async-saving");
100
-
101
- if (!eventTarget.classList.contains("disable-prevent-form")) {
102
- activeControls.forEach(function (control) {
103
- control.setAttribute("readonly", "readonly");
104
- });
105
-
106
- if (submitter) {
107
- submitter.disabled = true;
108
- }
109
- }
110
-
111
- if (eventTarget) {
112
- const loader = eventTarget.querySelector(".form-loader");
113
-
114
- if (loader) {
115
- loader.classList.add("loading");
116
- }
117
- }
118
- })
119
- .setHandler(function () {
120
- eventTarget.classList.remove("async-saving");
121
-
122
- activeControls.forEach(function (control) {
123
- control.removeAttribute("readonly");
124
- });
125
-
126
- if (submitter) {
127
- submitter.disabled = false;
128
- }
129
-
130
- if (eventTarget) {
131
- const loader = eventTarget.querySelector(".small-loader");
132
-
133
- if (loader) {
134
- loader.classList.remove("loading");
135
- }
136
- }
137
- })
138
- .setErrorHandler(function () {
139
- eventTarget.classList.remove("async-saving");
140
-
141
- activeControls.forEach(function (control) {
142
- control.removeAttribute("readonly");
143
- });
144
-
145
- if (submitter) {
146
- submitter.disabled = false;
147
- }
148
-
149
- if (eventTarget) {
150
- const loader = eventTarget.querySelector(".small-loader");
151
-
152
- if (loader) {
153
- loader.classList.remove("loading");
154
- }
155
- }
156
- })
157
- .send();
158
- }
159
- };
160
- }
@@ -1,53 +0,0 @@
1
- import DOM from "../core/DOM";
2
-
3
- export default class AsyncDOM {
4
- invoke(domOps, element) {
5
- for (let i = 0; i < domOps.length; ++i) {
6
- let [type, selector, enableTarget, content] = domOps[i];
7
-
8
- let node = enableTarget && element || null;
9
-
10
- if (selector) {
11
- node = (node || document.documentElement).querySelector(selector);
12
- }
13
-
14
- if (__DEV__ && !node) {
15
- console.error(`Selector '${selector}' does not match anything!`)
16
- continue;
17
- }
18
-
19
- switch (type) {
20
- case "eval":
21
- (new Function(content)).apply(node);
22
- break;
23
- case "hide":
24
- node.style.display = "none";
25
- break;
26
- case "show":
27
- node.style.display = "";
28
- break;
29
- case "setContent":
30
- DOM.setContent(node, content.__html);
31
- break;
32
- case "appendContent":
33
- DOM.appendContent(node, content.__html);
34
- break;
35
- case "prependContent":
36
- DOM.prependContent(node, content.__html);
37
- break;
38
- case "insertAfter":
39
- DOM.insertAfter(node, content.__html);
40
- break;
41
- case "insertBefore":
42
- DOM.insertBefore(node, content.__html);
43
- break;
44
- case "remove":
45
- DOM.remove(node);
46
- break;
47
- case "replace":
48
- DOM.replace(node, content.__html);
49
- break;
50
- }
51
- }
52
- }
53
- };
@@ -1,21 +0,0 @@
1
- import AsyncDOM from "./AsyncDOM";
2
- import ServerJS from "../ServerJS";
3
-
4
- const _AsyncDOM = new AsyncDOM;
5
- const _ServerJS = new ServerJS;
6
-
7
- export default class AsyncResponse {
8
- handle(response, element) {
9
- const {domops, jsmods} = response;
10
-
11
- if (typeof response === 'object') {
12
- if (domops) {
13
- _AsyncDOM.invoke(domops, element);
14
- }
15
-
16
- if (jsmods) {
17
- _ServerJS.handle(jsmods);
18
- }
19
- }
20
- }
21
- };
package/src/core/$.js DELETED
@@ -1,3 +0,0 @@
1
- export default function (elementId) {
2
- return document.getElementById(elementId);
3
- }