-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathboot.js
4801 lines (4198 loc) · 151 KB
/
boot.js
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
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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// @generated
/*eslint semi:[0], no-native-reassign:[0]*/
global = this;
(function (modules) {
// Bundle allows the run-time to extract already-loaded modules from the
// boot bundle.
var bundle = {};
var main;
// Unpack module tuples into module objects.
for (var i = 0; i < modules.length; i++) {
var module = modules[i];
module = modules[i] = new Module(
module[0],
module[1],
module[2],
module[3],
module[4]
);
bundle[module.filename] = module;
}
function Module(id, dirname, basename, dependencies, factory) {
this.id = id;
this.dirname = dirname;
this.filename = dirname + "/" + basename;
// Dependency map and factory are used to instantiate bundled modules.
this.dependencies = dependencies;
this.factory = factory;
}
Module.prototype._require = function () {
var module = this;
if (module.exports === void 0) {
module.exports = {};
var require = function (id) {
var index = module.dependencies[id];
var dependency = modules[index];
if (!dependency)
throw new Error("Bundle is missing a dependency: " + id);
return dependency._require();
};
require.main = main;
module.exports = module.factory(
require,
module.exports,
module,
module.filename,
module.dirname
) || module.exports;
}
return module.exports;
};
// Communicate the bundle to all bundled modules
Module.prototype.modules = bundle;
return function require(filename) {
main = bundle[filename];
main._require();
}
})([["browser-asap.js","asap","browser-asap.js",{"./raw":1},function (require, exports, module, __filename, __dirname){
// asap/browser-asap.js
// --------------------
"use strict";
// rawAsap provides everything we need except exception management.
var rawAsap = require("./raw");
// RawTasks are recycled to reduce GC churn.
var freeTasks = [];
// We queue errors to ensure they are thrown in right order (FIFO).
// Array-as-queue is good enough here, since we are just dealing with exceptions.
var pendingErrors = [];
var requestErrorThrow = rawAsap.makeRequestCallFromTimer(throwFirstError);
function throwFirstError() {
if (pendingErrors.length) {
throw pendingErrors.shift();
}
}
/**
* Calls a task as soon as possible after returning, in its own event, with priority
* over other events like animation, reflow, and repaint. An error thrown from an
* event will not interrupt, nor even substantially slow down the processing of
* other events, but will be rather postponed to a lower priority event.
* @param {{call}} task A callable object, typically a function that takes no
* arguments.
*/
module.exports = asap;
function asap(task) {
var rawTask;
if (freeTasks.length) {
rawTask = freeTasks.pop();
} else {
rawTask = new RawTask();
}
rawTask.task = task;
rawAsap(rawTask);
}
// We wrap tasks with recyclable task objects. A task object implements
// `call`, just like a function.
function RawTask() {
this.task = null;
}
// The sole purpose of wrapping the task is to catch the exception and recycle
// the task object after its single use.
RawTask.prototype.call = function () {
try {
this.task.call();
} catch (error) {
if (asap.onerror) {
// This hook exists purely for testing purposes.
// Its name will be periodically randomized to break any code that
// depends on its existence.
asap.onerror(error);
} else {
// In a web browser, exceptions are not fatal. However, to avoid
// slowing down the queue of pending tasks, we rethrow the error in a
// lower priority turn.
pendingErrors.push(error);
requestErrorThrow();
}
} finally {
this.task = null;
freeTasks[freeTasks.length] = this;
}
};
}],["browser-raw.js","asap","browser-raw.js",{},function (require, exports, module, __filename, __dirname){
// asap/browser-raw.js
// -------------------
"use strict";
// Use the fastest means possible to execute a task in its own turn, with
// priority over other events including IO, animation, reflow, and redraw
// events in browsers.
//
// An exception thrown by a task will permanently interrupt the processing of
// subsequent tasks. The higher level `asap` function ensures that if an
// exception is thrown by a task, that the task queue will continue flushing as
// soon as possible, but if you use `rawAsap` directly, you are responsible to
// either ensure that no exceptions are thrown from your task, or to manually
// call `rawAsap.requestFlush` if an exception is thrown.
module.exports = rawAsap;
function rawAsap(task) {
if (!queue.length) {
requestFlush();
flushing = true;
}
// Equivalent to push, but avoids a function call.
queue[queue.length] = task;
}
var queue = [];
// Once a flush has been requested, no further calls to `requestFlush` are
// necessary until the next `flush` completes.
var flushing = false;
// `requestFlush` is an implementation-specific method that attempts to kick
// off a `flush` event as quickly as possible. `flush` will attempt to exhaust
// the event queue before yielding to the browser's own event loop.
var requestFlush;
// The position of the next task to execute in the task queue. This is
// preserved between calls to `flush` so that it can be resumed if
// a task throws an exception.
var index = 0;
// If a task schedules additional tasks recursively, the task queue can grow
// unbounded. To prevent memory exhaustion, the task queue will periodically
// truncate already-completed tasks.
var capacity = 1024;
// The flush function processes all tasks that have been scheduled with
// `rawAsap` unless and until one of those tasks throws an exception.
// If a task throws an exception, `flush` ensures that its state will remain
// consistent and will resume where it left off when called again.
// However, `flush` does not make any arrangements to be called again if an
// exception is thrown.
function flush() {
while (index < queue.length) {
var currentIndex = index;
// Advance the index before calling the task. This ensures that we will
// begin flushing on the next task the task throws an error.
index = index + 1;
queue[currentIndex].call();
// Prevent leaking memory for long chains of recursive calls to `asap`.
// If we call `asap` within tasks scheduled by `asap`, the queue will
// grow, but to avoid an O(n) walk for every task we execute, we don't
// shift tasks off the queue after they have been executed.
// Instead, we periodically shift 1024 tasks off the queue.
if (index > capacity) {
// Manually shift all values starting at the index back to the
// beginning of the queue.
for (var scan = 0, newLength = queue.length - index; scan < newLength; scan++) {
queue[scan] = queue[scan + index];
}
queue.length -= index;
index = 0;
}
}
queue.length = 0;
index = 0;
flushing = false;
}
// `requestFlush` is implemented using a strategy based on data collected from
// every available SauceLabs Selenium web driver worker at time of writing.
// https://docs.google.com/spreadsheets/d/1mG-5UYGup5qxGdEMWkhP6BWCz053NUb2E1QoUTU16uA/edit#gid=783724593
// Safari 6 and 6.1 for desktop, iPad, and iPhone are the only browsers that
// have WebKitMutationObserver but not un-prefixed MutationObserver.
// Must use `global` instead of `window` to work in both frames and web
// workers. `global` is a provision of Browserify, Mr, Mrs, or Mop.
var BrowserMutationObserver = global.MutationObserver || global.WebKitMutationObserver;
// MutationObservers are desirable because they have high priority and work
// reliably everywhere they are implemented.
// They are implemented in all modern browsers.
//
// - Android 4-4.3
// - Chrome 26-34
// - Firefox 14-29
// - Internet Explorer 11
// - iPad Safari 6-7.1
// - iPhone Safari 7-7.1
// - Safari 6-7
if (typeof BrowserMutationObserver === "function") {
requestFlush = makeRequestCallFromMutationObserver(flush);
// MessageChannels are desirable because they give direct access to the HTML
// task queue, are implemented in Internet Explorer 10, Safari 5.0-1, and Opera
// 11-12, and in web workers in many engines.
// Although message channels yield to any queued rendering and IO tasks, they
// would be better than imposing the 4ms delay of timers.
// However, they do not work reliably in Internet Explorer or Safari.
// Internet Explorer 10 is the only browser that has setImmediate but does
// not have MutationObservers.
// Although setImmediate yields to the browser's renderer, it would be
// preferrable to falling back to setTimeout since it does not have
// the minimum 4ms penalty.
// Unfortunately there appears to be a bug in Internet Explorer 10 Mobile (and
// Desktop to a lesser extent) that renders both setImmediate and
// MessageChannel useless for the purposes of ASAP.
// https://github.com/kriskowal/q/issues/396
// Timers are implemented universally.
// We fall back to timers in workers in most engines, and in foreground
// contexts in the following browsers.
// However, note that even this simple case requires nuances to operate in a
// broad spectrum of browsers.
//
// - Firefox 3-13
// - Internet Explorer 6-9
// - iPad Safari 4.3
// - Lynx 2.8.7
} else {
requestFlush = makeRequestCallFromTimer(flush);
}
// `requestFlush` requests that the high priority event queue be flushed as
// soon as possible.
// This is useful to prevent an error thrown in a task from stalling the event
// queue if the exception handled by Node.js’s
// `process.on("uncaughtException")` or by a domain.
rawAsap.requestFlush = requestFlush;
// To request a high priority event, we induce a mutation observer by toggling
// the text of a text node between "1" and "-1".
function makeRequestCallFromMutationObserver(callback) {
var toggle = 1;
var observer = new BrowserMutationObserver(callback);
var node = document.createTextNode("");
observer.observe(node, {characterData: true});
return function requestCall() {
toggle = -toggle;
node.data = toggle;
};
}
// The message channel technique was discovered by Malte Ubl and was the
// original foundation for this library.
// http://www.nonblocking.io/2011/06/windownexttick.html
// Safari 6.0.5 (at least) intermittently fails to create message ports on a
// page's first load. Thankfully, this version of Safari supports
// MutationObservers, so we don't need to fall back in that case.
// function makeRequestCallFromMessageChannel(callback) {
// var channel = new MessageChannel();
// channel.port1.onmessage = callback;
// return function requestCall() {
// channel.port2.postMessage(0);
// };
// }
// For reasons explained above, we are also unable to use `setImmediate`
// under any circumstances.
// Even if we were, there is another bug in Internet Explorer 10.
// It is not sufficient to assign `setImmediate` to `requestFlush` because
// `setImmediate` must be called *by name* and therefore must be wrapped in a
// closure.
// Never forget.
// function makeRequestCallFromSetImmediate(callback) {
// return function requestCall() {
// setImmediate(callback);
// };
// }
// Safari 6.0 has a problem where timers will get lost while the user is
// scrolling. This problem does not impact ASAP because Safari 6.0 supports
// mutation observers, so that implementation is used instead.
// However, if we ever elect to use timers in Safari, the prevalent work-around
// is to add a scroll event listener that calls for a flush.
// `setTimeout` does not call the passed callback if the delay is less than
// approximately 7 in web workers in Firefox 8 through 18, and sometimes not
// even then.
function makeRequestCallFromTimer(callback) {
return function requestCall() {
// We dispatch a timeout with a specified delay of 0 for engines that
// can reliably accommodate that request. This will usually be snapped
// to a 4 milisecond delay, but once we're flushing, there's no delay
// between events.
var timeoutHandle = setTimeout(handleTimer, 0);
// However, since this timer gets frequently dropped in Firefox
// workers, we enlist an interval handle that will try to fire
// an event 20 times per second until it succeeds.
var intervalHandle = setInterval(handleTimer, 50);
function handleTimer() {
// Whichever timer succeeds will cancel both timers and
// execute the callback.
clearTimeout(timeoutHandle);
clearInterval(intervalHandle);
callback();
}
};
}
// This is for `asap.js` only.
// Its name will be periodically randomized to break any code that depends on
// its existence.
rawAsap.makeRequestCallFromTimer = makeRequestCallFromTimer;
// ASAP was originally a nextTick shim included in Q. This was factored out
// into this ASAP package. It was later adapted to RSVP which made further
// amendments. These decisions, particularly to marginalize MessageChannel and
// to capture the MutationObserver implementation in a closure, were integrated
// back into ASAP proper.
// https://github.com/tildeio/rsvp.js/blob/cddf7232546a9cf858524b75cde6f9edf72620a7/lib/rsvp/asap.js
}],["boot-entry.js","gutentag","boot-entry.js",{"system/boot-entry":11,"./document":3,"./scope":4},function (require, exports, module, __filename, __dirname){
// gutentag/boot-entry.js
// ----------------------
"use strict";
var boot = require("system/boot-entry");
var Document = require("./document");
var Scope = require("./scope");
module.exports = render;
function render() {
return boot()
.then(function (Main) {
var scope = new Scope();
var document = new Document(window.document.body);
new Main(document.documentElement, scope);
});
}
if (require.main === module) {
render().done();
}
}],["document.js","gutentag","document.js",{"koerper":5},function (require, exports, module, __filename, __dirname){
// gutentag/document.js
// --------------------
"use strict";
module.exports = require("koerper");
}],["scope.js","gutentag","scope.js",{},function (require, exports, module, __filename, __dirname){
// gutentag/scope.js
// -----------------
"use strict";
module.exports = Scope;
function Scope() {
this.root = this;
this.components = Object.create(null);
this.componentsFor = Object.create(null);
}
Scope.prototype.nest = function () {
var child = Object.create(this);
child.parent = this;
child.caller = this.caller && this.caller.nest();
return child;
};
Scope.prototype.nestComponents = function () {
var child = this.nest();
child.components = Object.create(this.components);
child.componentsFor = Object.create(this.componentsFor);
return child;
};
// TODO deprecated
Scope.prototype.set = function (id, component) {
console.log(new Error().stack);
this.hookup(id, component);
};
Scope.prototype.hookup = function (id, component) {
var scope = this;
scope.components[id] = component;
if (scope.this.hookup) {
scope.this.hookup(id, component, scope);
} else if (scope.this.add) {
// TODO deprecated
scope.this.add(component, id, scope);
}
var exportId = scope.this.exports && scope.this.exports[id];
if (exportId) {
var callerId = scope.caller.id;
scope.caller.hookup(callerId + ":" + exportId, component);
}
};
}],["koerper.js","koerper","koerper.js",{"wizdom":22},function (require, exports, module, __filename, __dirname){
// koerper/koerper.js
// ------------------
"use strict";
var BaseDocument = require("wizdom");
var BaseNode = BaseDocument.prototype.Node;
var BaseElement = BaseDocument.prototype.Element;
var BaseTextNode = BaseDocument.prototype.TextNode;
module.exports = Document;
function Document(actualNode) {
Node.call(this, this);
this.actualNode = actualNode;
this.actualDocument = actualNode.ownerDocument;
this.documentElement = this.createBody();
this.documentElement.parentNode = this;
actualNode.appendChild(this.documentElement.actualNode);
this.firstChild = this.documentElement;
this.lastChild = this.documentElement;
}
Document.prototype = Object.create(BaseDocument.prototype);
Document.prototype.Node = Node;
Document.prototype.Element = Element;
Document.prototype.TextNode = TextNode;
Document.prototype.Body = Body;
Document.prototype.OpaqueHtml = OpaqueHtml;
Document.prototype.createBody = function (label) {
return new this.Body(this, label);
};
Document.prototype.getActualParent = function () {
return this.actualNode;
};
function Node(document) {
BaseNode.call(this, document);
this.actualNode = null;
}
Node.prototype = Object.create(BaseNode.prototype);
Node.prototype.constructor = Node;
Node.prototype.insertBefore = function insertBefore(childNode, nextSibling) {
if (nextSibling && nextSibling.parentNode !== this) {
throw new Error("Can't insert before node that is not a child of parent");
}
BaseNode.prototype.insertBefore.call(this, childNode, nextSibling);
var actualParentNode = this.getActualParent();
var actualNextSibling;
if (nextSibling) {
actualNextSibling = nextSibling.getActualFirstChild();
}
if (!actualNextSibling) {
actualNextSibling = this.getActualNextSibling();
}
if (actualNextSibling && actualNextSibling.parentNode !== actualParentNode) {
actualNextSibling = null;
}
actualParentNode.insertBefore(childNode.actualNode, actualNextSibling || null);
childNode.inject();
return childNode;
};
Node.prototype.removeChild = function removeChild(childNode) {
if (!childNode) {
throw new Error("Can't remove child " + childNode);
}
childNode.extract();
this.getActualParent().removeChild(childNode.actualNode);
BaseNode.prototype.removeChild.call(this, childNode);
};
Node.prototype.setAttribute = function setAttribute(key, value) {
this.actualNode.setAttribute(key, value);
};
Node.prototype.getAttribute = function getAttribute(key) {
this.actualNode.getAttribute(key);
};
Node.prototype.hasAttribute = function hasAttribute(key) {
this.actualNode.hasAttribute(key);
};
Node.prototype.removeAttribute = function removeAttribute(key) {
this.actualNode.removeAttribute(key);
};
Node.prototype.addEventListener = function addEventListener(name, handler, capture) {
this.actualNode.addEventListener(name, handler, capture);
};
Node.prototype.removeEventListener = function removeEventListener(name, handler, capture) {
this.actualNode.removeEventListener(name, handler, capture);
};
Node.prototype.inject = function injectNode() { };
Node.prototype.extract = function extractNode() { };
Node.prototype.getActualParent = function () {
return this.actualNode;
};
Node.prototype.getActualFirstChild = function () {
return this.actualNode;
};
Node.prototype.getActualNextSibling = function () {
return null;
};
Object.defineProperty(Node.prototype, "innerHTML", {
get: function () {
return this.actualNode.innerHTML;
}//,
//set: function (html) {
// // TODO invalidate any subcontained child nodes
// this.actualNode.innerHTML = html;
//}
});
function Element(document, type, namespace) {
BaseNode.call(this, document, namespace);
if (namespace) {
this.actualNode = document.actualDocument.createElementNS(namespace, type);
} else {
this.actualNode = document.actualDocument.createElement(type);
}
this.attributes = this.actualNode.attributes;
}
Element.prototype = Object.create(Node.prototype);
Element.prototype.constructor = Element;
Element.prototype.nodeType = 1;
function TextNode(document, text) {
Node.call(this, document);
this.actualNode = document.actualDocument.createTextNode(text);
}
TextNode.prototype = Object.create(Node.prototype);
TextNode.prototype.constructor = TextNode;
TextNode.prototype.nodeType = 3;
Object.defineProperty(TextNode.prototype, "data", {
set: function (data) {
this.actualNode.data = data;
},
get: function () {
return this.actualNode.data;
}
});
// if parentNode is null, the body is extracted
// if parentNode is non-null, the body is inserted
function Body(document, label) {
Node.call(this, document);
this.actualNode = document.actualDocument.createTextNode("");
//this.actualNode = document.actualDocument.createComment(label || "");
this.actualFirstChild = null;
this.actualBody = document.actualDocument.createElement("BODY");
}
Body.prototype = Object.create(Node.prototype);
Body.prototype.constructor = Body;
Body.prototype.nodeType = 13;
Body.prototype.extract = function extract() {
var body = this.actualBody;
var lastChild = this.actualNode;
var parentNode = this.parentNode.getActualParent();
var at = this.getActualFirstChild();
var next;
while (at && at !== lastChild) {
next = at.nextSibling;
if (body) {
body.appendChild(at);
} else {
parentNode.removeChild(at);
}
at = next;
}
};
Body.prototype.inject = function inject() {
if (!this.parentNode) {
throw new Error("Can't inject without a parent node");
}
var body = this.actualBody;
var lastChild = this.actualNode;
var parentNode = this.parentNode.getActualParent();
var at = body.firstChild;
var next;
while (at) {
next = at.nextSibling;
parentNode.insertBefore(at, lastChild);
at = next;
}
};
Body.prototype.getActualParent = function () {
if (this.parentNode) {
return this.parentNode.getActualParent();
} else {
return this.actualBody;
}
};
Body.prototype.getActualFirstChild = function () {
if (this.firstChild) {
return this.firstChild.getActualFirstChild();
} else {
return this.actualNode;
}
};
Body.prototype.getActualNextSibling = function () {
return this.actualNode;
};
Object.defineProperty(Body.prototype, "innerHTML", {
get: function () {
if (this.parentNode) {
this.extract();
var html = this.actualBody.innerHTML;
this.inject();
return html;
} else {
return this.actualBody.innerHTML;
}
},
set: function (html) {
if (this.parentNode) {
this.extract();
this.actualBody.innerHTML = html;
this.firstChild = this.lastChild = new OpaqueHtml(
this.ownerDocument,
this.actualBody
);
this.inject();
} else {
this.actualBody.innerHTML = html;
this.firstChild = this.lastChild = new OpaqueHtml(
this.ownerDocument,
this.actualBody
);
}
return html;
}
});
function OpaqueHtml(ownerDocument, body) {
Node.call(this, ownerDocument);
this.actualFirstChild = body.firstChild;
}
OpaqueHtml.prototype = Object.create(Node.prototype);
OpaqueHtml.prototype.constructor = OpaqueHtml;
OpaqueHtml.prototype.getActualFirstChild = function getActualFirstChild() {
return this.actualFirstChild;
};
}],["array-iterator.js","pop-iterate","array-iterator.js",{"./iteration":7},function (require, exports, module, __filename, __dirname){
// pop-iterate/array-iterator.js
// -----------------------------
"use strict";
var Iteration = require("./iteration");
module.exports = ArrayIterator;
function ArrayIterator(iterable, start, stop, step) {
this.array = iterable;
this.start = start || 0;
this.stop = stop || Infinity;
this.step = step || 1;
}
ArrayIterator.prototype.next = function () {
var iteration;
if (this.start < Math.min(this.array.length, this.stop)) {
iteration = new Iteration(this.array[this.start], false, this.start);
this.start += this.step;
} else {
iteration = new Iteration(undefined, true);
}
return iteration;
};
}],["iteration.js","pop-iterate","iteration.js",{},function (require, exports, module, __filename, __dirname){
// pop-iterate/iteration.js
// ------------------------
"use strict";
module.exports = Iteration;
function Iteration(value, done, index) {
this.value = value;
this.done = done;
this.index = index;
}
Iteration.prototype.equals = function (other) {
return (
typeof other == 'object' &&
other.value === this.value &&
other.done === this.done &&
other.index === this.index
);
};
}],["object-iterator.js","pop-iterate","object-iterator.js",{"./iteration":7,"./array-iterator":6},function (require, exports, module, __filename, __dirname){
// pop-iterate/object-iterator.js
// ------------------------------
"use strict";
var Iteration = require("./iteration");
var ArrayIterator = require("./array-iterator");
module.exports = ObjectIterator;
function ObjectIterator(iterable, start, stop, step) {
this.object = iterable;
this.keysIterator = new ArrayIterator(Object.keys(iterable), start, stop, step);
}
ObjectIterator.prototype.next = function () {
var iteration = this.keysIterator.next();
if (iteration.done) {
return iteration;
}
var key = iteration.value;
return new Iteration(this.object[key], false, key);
};
}],["pop-iterate.js","pop-iterate","pop-iterate.js",{"./array-iterator":6,"./object-iterator":8},function (require, exports, module, __filename, __dirname){
// pop-iterate/pop-iterate.js
// --------------------------
"use strict";
var ArrayIterator = require("./array-iterator");
var ObjectIterator = require("./object-iterator");
module.exports = iterate;
function iterate(iterable, start, stop, step) {
if (!iterable) {
return empty;
} else if (Array.isArray(iterable)) {
return new ArrayIterator(iterable, start, stop, step);
} else if (typeof iterable.next === "function") {
return iterable;
} else if (typeof iterable.iterate === "function") {
return iterable.iterate(start, stop, step);
} else if (typeof iterable === "object") {
return new ObjectIterator(iterable);
} else {
throw new TypeError("Can't iterate " + iterable);
}
}
}],["q.js","q","q.js",{"weak-map":21,"pop-iterate":9,"asap":0},function (require, exports, module, __filename, __dirname){
// q/q.js
// ------
/* vim:ts=4:sts=4:sw=4: */
/*!
*
* Copyright 2009-2013 Kris Kowal under the terms of the MIT
* license found at http://github.com/kriskowal/q/raw/master/LICENSE
*
* With parts by Tyler Close
* Copyright 2007-2009 Tyler Close under the terms of the MIT X license found
* at http://www.opensource.org/licenses/mit-license.html
* Forked at ref_send.js version: 2009-05-11
*
* With parts by Mark Miller
* Copyright (C) 2011 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
/*global -WeakMap */
"use strict";
var hasStacks = false;
try {
throw new Error();
} catch (e) {
hasStacks = !!e.stack;
}
// All code after this point will be filtered from stack traces reported
// by Q.
var qStartingLine = captureLine();
var qFileName;
var WeakMap = require("weak-map");
var iterate = require("pop-iterate");
var asap = require("asap");
function isObject(value) {
return value === Object(value);
}
// long stack traces
var STACK_JUMP_SEPARATOR = "From previous event:";
function makeStackTraceLong(error, promise) {
// If possible, transform the error stack trace by removing Node and Q
// cruft, then concatenating with the stack trace of `promise`. See #57.
if (hasStacks &&
promise.stack &&
typeof error === "object" &&
error !== null &&
error.stack &&
error.stack.indexOf(STACK_JUMP_SEPARATOR) === -1
) {
var stacks = [];
for (var p = promise; !!p && handlers.get(p); p = handlers.get(p).became) {
if (p.stack) {
stacks.unshift(p.stack);
}
}
stacks.unshift(error.stack);
var concatedStacks = stacks.join("\n" + STACK_JUMP_SEPARATOR + "\n");
error.stack = filterStackString(concatedStacks);
}
}
function filterStackString(stackString) {
if (Q.isIntrospective) {
return stackString;
}
var lines = stackString.split("\n");
var desiredLines = [];
for (var i = 0; i < lines.length; ++i) {
var line = lines[i];
if (!isInternalFrame(line) && !isNodeFrame(line) && line) {
desiredLines.push(line);
}
}
return desiredLines.join("\n");
}
function isNodeFrame(stackLine) {
return stackLine.indexOf("(module.js:") !== -1 ||
stackLine.indexOf("(node.js:") !== -1;
}
function getFileNameAndLineNumber(stackLine) {
// Named functions: "at functionName (filename:lineNumber:columnNumber)"
// In IE10 function name can have spaces ("Anonymous function") O_o
var attempt1 = /at .+ \((.+):(\d+):(?:\d+)\)$/.exec(stackLine);
if (attempt1) {
return [attempt1[1], Number(attempt1[2])];
}
// Anonymous functions: "at filename:lineNumber:columnNumber"
var attempt2 = /at ([^ ]+):(\d+):(?:\d+)$/.exec(stackLine);
if (attempt2) {
return [attempt2[1], Number(attempt2[2])];
}
// Firefox style: "function@filename:lineNumber or @filename:lineNumber"
var attempt3 = /.*@(.+):(\d+)$/.exec(stackLine);
if (attempt3) {
return [attempt3[1], Number(attempt3[2])];
}
}
function isInternalFrame(stackLine) {
var fileNameAndLineNumber = getFileNameAndLineNumber(stackLine);
if (!fileNameAndLineNumber) {
return false;
}
var fileName = fileNameAndLineNumber[0];
var lineNumber = fileNameAndLineNumber[1];
return fileName === qFileName &&
lineNumber >= qStartingLine &&
lineNumber <= qEndingLine;
}
// discover own file name and line number range for filtering stack
// traces
function captureLine() {
if (!hasStacks) {
return;
}
try {
throw new Error();
} catch (e) {
var lines = e.stack.split("\n");
var firstLine = lines[0].indexOf("@") > 0 ? lines[1] : lines[2];
var fileNameAndLineNumber = getFileNameAndLineNumber(firstLine);
if (!fileNameAndLineNumber) {
return;
}
qFileName = fileNameAndLineNumber[0];
return fileNameAndLineNumber[1];
}
}
function deprecate(callback, name, alternative) {
return function Q_deprecate() {
if (
typeof console !== "undefined" &&
typeof console.warn === "function"
) {
if (alternative) {
console.warn(
name + " is deprecated, use " + alternative + " instead.",
new Error("").stack
);
} else {
console.warn(
name + " is deprecated.",
new Error("").stack
);