bigpipe-util 0.2.13 → 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.
- package/README.md +124 -124
- package/{src → dist}/BigPipe.js +148 -170
- package/dist/Pagelet.js +111 -0
- package/dist/Primer.js +117 -0
- package/{src → dist}/ServerJS.js +40 -40
- package/dist/async/AsyncDOM.js +58 -0
- package/{src → dist}/async/AsyncRequest.js +182 -210
- package/dist/async/AsyncResponse.js +28 -0
- package/dist/core/$.js +9 -0
- package/{src → dist}/core/Arbiter.js +53 -53
- package/{src → dist}/core/DOM.js +39 -41
- package/{src → dist}/core/Dialog.js +129 -142
- package/dist/core/Parent.js +39 -0
- package/dist/core/ReloadPage.js +15 -0
- package/dist/core/ServerRedirect.js +14 -0
- package/{src → dist}/core/copyProperties.js +32 -31
- package/dist/core/onAfterLoad.js +18 -0
- package/{src → dist}/core/replaceTransportMarkers.js +32 -27
- package/{src → dist}/core/waitForLoad.js +13 -24
- package/package.json +21 -2
- package/.editorconfig +0 -9
- package/CHANGELOG.md +0 -109
- package/bigpipe.svg +0 -13
- package/src/Pagelet.js +0 -131
- package/src/Primer.js +0 -160
- package/src/async/AsyncDOM.js +0 -55
- package/src/async/AsyncResponse.js +0 -21
- package/src/core/$.js +0 -3
- package/src/core/Parent.js +0 -38
- package/src/core/ReloadPage.js +0 -9
- package/src/core/ServerRedirect.js +0 -7
- package/src/core/onAfterLoad.js +0 -13
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _AsyncDOM2 = _interopRequireDefault(require("./AsyncDOM"));
|
|
8
|
+
var _ServerJS2 = _interopRequireDefault(require("../ServerJS"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
const _AsyncDOM = new _AsyncDOM2.default();
|
|
11
|
+
const _ServerJS = new _ServerJS2.default();
|
|
12
|
+
class AsyncResponse {
|
|
13
|
+
handle(response, element) {
|
|
14
|
+
const {
|
|
15
|
+
domops,
|
|
16
|
+
jsmods
|
|
17
|
+
} = response;
|
|
18
|
+
if (typeof response === 'object') {
|
|
19
|
+
if (domops) {
|
|
20
|
+
_AsyncDOM.invoke(domops, element);
|
|
21
|
+
}
|
|
22
|
+
if (jsmods) {
|
|
23
|
+
_ServerJS.handle(jsmods);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.default = AsyncResponse;
|
package/dist/core/$.js
ADDED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
subscribe(toWhat, withWhat) {
|
|
38
|
-
const list = this.getSubscribers(toWhat);
|
|
39
|
-
list.push(withWhat);
|
|
40
|
-
return this;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
const _events = {};
|
|
8
|
+
class Arbiter {
|
|
9
|
+
constructor() {
|
|
10
|
+
this._events = _events;
|
|
11
|
+
}
|
|
12
|
+
inform(what, ...args) {
|
|
13
|
+
const list = [...this.getSubscribers(what)];
|
|
14
|
+
for (let i = 0; i < list.length; i++) {
|
|
15
|
+
if (list[i] === null) {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
list[i].apply(this, args);
|
|
20
|
+
} catch (e) {
|
|
21
|
+
window.setTimeout(() => {
|
|
22
|
+
throw e;
|
|
23
|
+
}, 0);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
getSubscribers(toWhat) {
|
|
29
|
+
return this._events[toWhat] || (this._events[toWhat] = []);
|
|
30
|
+
}
|
|
31
|
+
clearSubscribers(toWhat) {
|
|
32
|
+
if (toWhat) {
|
|
33
|
+
this._events[toWhat] = [];
|
|
34
|
+
}
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
subscribe(toWhat, withWhat) {
|
|
38
|
+
const list = this.getSubscribers(toWhat);
|
|
39
|
+
list.push(withWhat);
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
unsubscribe(toWhat, withWhat) {
|
|
43
|
+
const list = this.getSubscribers(toWhat);
|
|
44
|
+
for (let i = 0; i < list.length; i++) {
|
|
45
|
+
if (list[i] === withWhat) {
|
|
46
|
+
list.splice(i, 1);
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.default = Arbiter;
|
package/{src → dist}/core/DOM.js
RENAMED
|
@@ -1,41 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
node.
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
node.insertAdjacentHTML(
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
replace(node, content) {
|
|
29
|
-
node.outerHTML = content;
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
function removeNode(node) {
|
|
8
|
+
if (node.parentNode) {
|
|
9
|
+
node.parentNode.removeChild(node);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
var _default = exports.default = {
|
|
13
|
+
prependContent(node, content) {
|
|
14
|
+
node.insertAdjacentHTML('afterbegin', content);
|
|
15
|
+
},
|
|
16
|
+
insertAfter(node, content) {
|
|
17
|
+
node.insertAdjacentHTML('afterend', content);
|
|
18
|
+
},
|
|
19
|
+
insertBefore(node, content) {
|
|
20
|
+
node.insertAdjacentHTML('beforebegin', content);
|
|
21
|
+
},
|
|
22
|
+
setContent(node, content) {
|
|
23
|
+
node.innerHTML = content;
|
|
24
|
+
},
|
|
25
|
+
appendContent(node, content) {
|
|
26
|
+
node.insertAdjacentHTML('beforeend', content);
|
|
27
|
+
},
|
|
28
|
+
replace(node, content) {
|
|
29
|
+
node.outerHTML = content;
|
|
30
|
+
},
|
|
31
|
+
remove(node) {
|
|
32
|
+
removeNode(node);
|
|
33
|
+
},
|
|
34
|
+
empty(node) {
|
|
35
|
+
while (node.firstChild) {
|
|
36
|
+
removeNode(node.firstChild);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
@@ -1,142 +1,129 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
render(options, args) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
shown = true;
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
_makeDialog(content, className = '') {
|
|
136
|
-
this.id = `js_${dialogId.toString(16)}`;
|
|
137
|
-
return `
|
|
138
|
-
<div id="${this.id}" class="modal fade ${className}" tabindex="-1" role="dialog">
|
|
139
|
-
${content}
|
|
140
|
-
</div>`;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _modal2 = _interopRequireDefault(require("modal-vanilla/lib/modal"));
|
|
8
|
+
var _DOM = _interopRequireDefault(require("./DOM"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
const DEFAULT_Z_INDEX = 1040;
|
|
11
|
+
let stack = [];
|
|
12
|
+
let dialogId = 1;
|
|
13
|
+
let zIndex;
|
|
14
|
+
let originalBodyPad = null;
|
|
15
|
+
_modal2.default.prototype._handleKeydownEvent = function (event) {
|
|
16
|
+
if (event.which === 27 && this._options.keyboard) {
|
|
17
|
+
const currentModal = stack[stack.length - 1];
|
|
18
|
+
if (currentModal.el.isEqualNode(this.el)) {
|
|
19
|
+
this.emit('dismiss', this, event, null);
|
|
20
|
+
this.hide();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
class Dialog {
|
|
25
|
+
close(limit = -1) {
|
|
26
|
+
let modals;
|
|
27
|
+
if (limit > -1) {
|
|
28
|
+
modals = stack.slice(-limit);
|
|
29
|
+
} else {
|
|
30
|
+
modals = stack;
|
|
31
|
+
}
|
|
32
|
+
modals.forEach(dialog => dialog.hide());
|
|
33
|
+
}
|
|
34
|
+
closeCurrent() {
|
|
35
|
+
const dialog = stack.pop();
|
|
36
|
+
if (dialog) {
|
|
37
|
+
dialog.hide();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
render(options, args) {
|
|
41
|
+
_DOM.default.appendContent(document.body, this._makeDialog(options.content, options.dialogClassName));
|
|
42
|
+
dialogId++;
|
|
43
|
+
return this._maybeWithTimeout(options.timeout, () => this._show({
|
|
44
|
+
el: document.getElementById(this.id),
|
|
45
|
+
animate: this._getOption(options, 'animate', false),
|
|
46
|
+
keyboard: this._getOption(options, 'keyboard', true),
|
|
47
|
+
backdrop: this._getOption(options, 'backdrop', true),
|
|
48
|
+
transition: this._getOption(options, 'transition', 0),
|
|
49
|
+
backdropTransition: this._getOption(options, 'backdropTransition', 0)
|
|
50
|
+
}, options.controller, args));
|
|
51
|
+
}
|
|
52
|
+
showFromModel(model, args) {
|
|
53
|
+
return this._maybeWithTimeout(model.timeout, () => this._show({
|
|
54
|
+
title: model.title || '',
|
|
55
|
+
content: model.body,
|
|
56
|
+
footer: model.footer || false,
|
|
57
|
+
animate: this._getOption(model, 'animate', false),
|
|
58
|
+
keyboard: this._getOption(model, 'keyboard', true),
|
|
59
|
+
backdrop: this._getOption(model, 'backdrop', true),
|
|
60
|
+
transition: this._getOption(model, 'transition', 0),
|
|
61
|
+
backdropTransition: this._getOption(model, 'backdropTransition', 0)
|
|
62
|
+
}, model.controller, args));
|
|
63
|
+
}
|
|
64
|
+
_maybeWithTimeout(timeout, callback) {
|
|
65
|
+
if (typeof timeout === 'number') {
|
|
66
|
+
return new Promise(resolve => setTimeout(() => resolve(callback()), timeout));
|
|
67
|
+
}
|
|
68
|
+
return callback();
|
|
69
|
+
}
|
|
70
|
+
_getOption(obj, key, defaultVal) {
|
|
71
|
+
return obj[key] !== null && obj[key] !== undefined ? obj[key] : defaultVal;
|
|
72
|
+
}
|
|
73
|
+
_show(options, controller, args) {
|
|
74
|
+
if (originalBodyPad === null) {
|
|
75
|
+
originalBodyPad = document.body.style.paddingRight;
|
|
76
|
+
}
|
|
77
|
+
const _modal = new _modal2.default(options);
|
|
78
|
+
stack.push(_modal);
|
|
79
|
+
if (controller) {
|
|
80
|
+
if (typeof controller === 'string') {
|
|
81
|
+
new (window.require(controller))(_modal, ...args);
|
|
82
|
+
} else if (typeof controller === 'function') {
|
|
83
|
+
controller(_modal, ...args);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const self = this;
|
|
87
|
+
return _modal.on('shown', function ({
|
|
88
|
+
el
|
|
89
|
+
}) {
|
|
90
|
+
zIndex = DEFAULT_Z_INDEX + 10 * stack.length;
|
|
91
|
+
el.style.zIndex = zIndex;
|
|
92
|
+
setTimeout(() => document.querySelector('.modal-backdrop').style.zIndex = zIndex - 1);
|
|
93
|
+
}).on('showBackdrop', this._fixBackdrop).on('hidden', function ({
|
|
94
|
+
el
|
|
95
|
+
}) {
|
|
96
|
+
stack = stack.filter(modal => {
|
|
97
|
+
return !modal.el.isEqualNode(el);
|
|
98
|
+
});
|
|
99
|
+
if (stack.length) {
|
|
100
|
+
document.body.classList.add('modal-open');
|
|
101
|
+
}
|
|
102
|
+
document.body.style.paddingRight = originalBodyPad;
|
|
103
|
+
zIndex -= 10;
|
|
104
|
+
self._fixBackdrop();
|
|
105
|
+
_DOM.default.remove(el);
|
|
106
|
+
}).show();
|
|
107
|
+
}
|
|
108
|
+
_fixBackdrop() {
|
|
109
|
+
const backdrops = document.querySelectorAll('.modal-backdrop');
|
|
110
|
+
let shown = false;
|
|
111
|
+
backdrops.forEach((backdrop, index) => {
|
|
112
|
+
if (shown || index > 0 && index === backdrops.length - 1) {
|
|
113
|
+
backdrop.style.display = 'none';
|
|
114
|
+
} else {
|
|
115
|
+
backdrop.style.zIndex = zIndex - 1;
|
|
116
|
+
backdrop.style.display = '';
|
|
117
|
+
shown = true;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
_makeDialog(content, className = '') {
|
|
122
|
+
this.id = `js_${dialogId.toString(16)}`;
|
|
123
|
+
return `
|
|
124
|
+
<div id="${this.id}" class="modal fade ${className}" tabindex="-1" role="dialog">
|
|
125
|
+
${content}
|
|
126
|
+
</div>`;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.default = Dialog;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.byAttribute = byAttribute;
|
|
7
|
+
exports.byClass = byClass;
|
|
8
|
+
exports.byTag = byTag;
|
|
9
|
+
exports.find = find;
|
|
10
|
+
var _CSSCore = _interopRequireDefault(require("fbjs/lib/CSSCore"));
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
function byTag(node, tagName) {
|
|
13
|
+
tagName = tagName.toUpperCase();
|
|
14
|
+
node = find(node, function (el) {
|
|
15
|
+
return el.nodeName === tagName;
|
|
16
|
+
});
|
|
17
|
+
return node instanceof Element ? node : null;
|
|
18
|
+
}
|
|
19
|
+
function byClass(node, className) {
|
|
20
|
+
node = find(node, function (el) {
|
|
21
|
+
return el instanceof Element && _CSSCore.default.hasClass(el, className);
|
|
22
|
+
});
|
|
23
|
+
return node instanceof Element ? node : null;
|
|
24
|
+
}
|
|
25
|
+
function byAttribute(node, attribute) {
|
|
26
|
+
node = find(node, function (el) {
|
|
27
|
+
return el instanceof Element && el.hasAttribute(attribute);
|
|
28
|
+
});
|
|
29
|
+
return node instanceof Element ? node : null;
|
|
30
|
+
}
|
|
31
|
+
function find(node, callback) {
|
|
32
|
+
while (node) {
|
|
33
|
+
if (callback(node)) {
|
|
34
|
+
return node;
|
|
35
|
+
}
|
|
36
|
+
node = node.parentNode;
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
class ReloadPage {
|
|
8
|
+
now() {
|
|
9
|
+
window.location.reload();
|
|
10
|
+
}
|
|
11
|
+
delay(delay) {
|
|
12
|
+
setTimeout(this.now.bind(this), delay);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.default = ReloadPage;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
class ServerRedirect {
|
|
8
|
+
redirectPageTo(url, delay = 0) {
|
|
9
|
+
setTimeout(function () {
|
|
10
|
+
window.location = url;
|
|
11
|
+
}, delay);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.default = ServerRedirect;
|
|
@@ -7,40 +7,41 @@
|
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
9
|
* @providesModule copyProperties
|
|
10
|
-
*/
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
10
|
+
*/
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
13
|
/**
|
|
14
14
|
* Copy properties from one or more objects (up to 5) into the first object.
|
|
15
15
|
* This is a shallow copy. It mutates the first object and also returns it.
|
|
16
16
|
*
|
|
17
17
|
* NOTE: `arguments` has a very significant performance penalty, which is why
|
|
18
18
|
* we don't support unlimited arguments.
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", {
|
|
21
|
+
value: true
|
|
22
|
+
});
|
|
23
|
+
exports.default = copyProperties;
|
|
24
|
+
function copyProperties(obj, a, b, c, d, e, f) {
|
|
25
|
+
obj = obj || {};
|
|
26
|
+
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
27
|
+
if (f) {
|
|
28
|
+
throw new Error('Too many arguments passed to copyProperties');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
var args = [a, b, c, d, e];
|
|
32
|
+
var ii = 0,
|
|
33
|
+
v;
|
|
34
|
+
while (args[ii]) {
|
|
35
|
+
v = args[ii++];
|
|
36
|
+
for (var k in v) {
|
|
37
|
+
obj[k] = v[k];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// IE ignores toString in object iteration.. See:
|
|
41
|
+
// webreflection.blogspot.com/2007/07/quick-fix-internet-explorer-and.html
|
|
42
|
+
if (Object.prototype.hasOwnProperty.call(v, 'toString') && typeof v.toString !== 'undefined' && obj.toString !== v.toString) {
|
|
43
|
+
obj.toString = v.toString;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return obj;
|
|
47
|
+
}
|