ovenplayer 0.10.49 → 0.10.51

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.
Files changed (34) hide show
  1. package/dist/ovenplayer.js +1 -1
  2. package/dist/ovenplayer.js.map +1 -1
  3. package/package.json +49 -49
  4. package/src/js/api/Configurator.js +1 -1
  5. package/src/js/api/ads/vast/Ad.js +237 -237
  6. package/src/js/api/caption/Loader.js +1 -1
  7. package/src/js/api/caption/Manager.js +1 -1
  8. package/src/js/api/caption/parser/VttParser.js +1541 -1542
  9. package/src/js/api/playlist/Manager.js +229 -229
  10. package/src/js/api/provider/html5/providers/Dash.js +286 -286
  11. package/src/js/api/provider/html5/providers/Hls.js +110 -2
  12. package/src/js/api/provider/html5/providers/WebRTC.js +2 -1
  13. package/src/js/api/provider/html5/providers/WebRTCLoader.js +35 -2
  14. package/src/js/api/provider/utils.js +69 -69
  15. package/src/js/ovenplayer.sdk.js +143 -143
  16. package/src/js/utils/likeA$.js +241 -242
  17. package/src/js/utils/resize-sensor.js +145 -168
  18. package/src/js/utils/strings.js +104 -104
  19. package/src/js/view/components/controls/settingPanel/audioTrackPanel.js +57 -57
  20. package/src/js/view/components/controls/settingPanel/main.js +1 -1
  21. package/src/js/view/components/controls/settingPanel/mainTemplate.js +29 -29
  22. package/src/js/view/components/controls/settingPanel/qualityPanel.js +68 -68
  23. package/src/js/view/components/controls/settingPanel/subtitleTrackPanel.js +56 -56
  24. package/src/js/view/components/helpers/captionViewer.js +97 -15
  25. package/src/js/view/components/helpers/captionViewerTemplate.js +1 -2
  26. package/src/js/view/components/helpers/waterMark.js +69 -69
  27. package/src/js/view/engine/OvenTemplate.js +158 -158
  28. package/src/js/view/global/PanelManager.js +47 -47
  29. package/src/stylesheet/ovenplayer.less +52 -21
  30. package/src/js/utils/adapter.js +0 -4944
  31. package/src/js/utils/captions/vttCue.js +0 -308
  32. package/src/js/utils/captions/vttRegion.js +0 -136
  33. package/src/js/utils/polyfills/dom.js +0 -634
  34. package/src/js/utils/underscore.js +0 -6
@@ -1,634 +0,0 @@
1
- /*
2
- * Copyright 2018 Joshua Bell
3
-
4
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
-
6
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7
-
8
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9
- * */
10
-
11
- (function(global) {
12
- 'use strict';
13
- if (!('window' in global && 'document' in global))
14
- return;
15
-
16
- //----------------------------------------------------------------------
17
- //
18
- // DOM
19
- // https://dom.spec.whatwg.org/
20
- //
21
- //----------------------------------------------------------------------
22
-
23
- // Document.querySelectorAll method
24
- // http://ajaxian.com/archives/creating-a-queryselector-for-ie-that-runs-at-native-speed
25
- // Needed for: IE7-
26
- if (!document.querySelectorAll) {
27
- document.querySelectorAll = function(selectors) {
28
- var style = document.createElement('style'), elements = [], element;
29
- document.documentElement.firstChild.appendChild(style);
30
- document._qsa = [];
31
-
32
- style.styleSheet.cssText = selectors + '{x-qsa:expression(document._qsa && document._qsa.push(this))}';
33
- window.scrollBy(0, 0);
34
- style.parentNode.removeChild(style);
35
-
36
- while (document._qsa.length) {
37
- element = document._qsa.shift();
38
- element.style.removeAttribute('x-qsa');
39
- elements.push(element);
40
- }
41
- document._qsa = null;
42
- return elements;
43
- };
44
- }
45
-
46
- // Document.querySelector method
47
- // Needed for: IE7-
48
- if (!document.querySelector) {
49
- document.querySelector = function(selectors) {
50
- var elements = document.querySelectorAll(selectors);
51
- return (elements.length) ? elements[0] : null;
52
- };
53
- }
54
-
55
- // Document.getElementsByClassName method
56
- // Needed for: IE8-
57
- if (!document.getElementsByClassName) {
58
- document.getElementsByClassName = function(classNames) {
59
- classNames = String(classNames).replace(/^|\s+/g, '.');
60
- return document.querySelectorAll(classNames);
61
- };
62
- }
63
-
64
- // Node interface constants
65
- // Needed for: IE8-
66
- global.Node = global.Node || function() { throw TypeError("Illegal constructor"); };
67
- [
68
- ['ELEMENT_NODE', 1],
69
- ['ATTRIBUTE_NODE', 2],
70
- ['TEXT_NODE', 3],
71
- ['CDATA_SECTION_NODE', 4],
72
- ['ENTITY_REFERENCE_NODE', 5],
73
- ['ENTITY_NODE', 6],
74
- ['PROCESSING_INSTRUCTION_NODE', 7],
75
- ['COMMENT_NODE', 8],
76
- ['DOCUMENT_NODE', 9],
77
- ['DOCUMENT_TYPE_NODE', 10],
78
- ['DOCUMENT_FRAGMENT_NODE', 11],
79
- ['NOTATION_NODE', 12]
80
- ].forEach(function(p) { if (!(p[0] in global.Node)) global.Node[p[0]] = p[1]; });
81
-
82
- // DOMException constants
83
- // Needed for: IE8-
84
- global.DOMException = global.DOMException || function() { throw TypeError("Illegal constructor"); };
85
- [
86
- ['INDEX_SIZE_ERR', 1],
87
- ['DOMSTRING_SIZE_ERR', 2],
88
- ['HIERARCHY_REQUEST_ERR', 3],
89
- ['WRONG_DOCUMENT_ERR', 4],
90
- ['INVALID_CHARACTER_ERR', 5],
91
- ['NO_DATA_ALLOWED_ERR', 6],
92
- ['NO_MODIFICATION_ALLOWED_ERR', 7],
93
- ['NOT_FOUND_ERR', 8],
94
- ['NOT_SUPPORTED_ERR', 9],
95
- ['INUSE_ATTRIBUTE_ERR', 10],
96
- ['INVALID_STATE_ERR', 11],
97
- ['SYNTAX_ERR', 12],
98
- ['INVALID_MODIFICATION_ERR', 13],
99
- ['NAMESPACE_ERR', 14],
100
- ['INVALID_ACCESS_ERR', 15]
101
- ].forEach(function(p) { if (!(p[0] in global.DOMException)) global.DOMException[p[0]] = p[1]; });
102
-
103
- // Event and EventTargets interfaces
104
- // Needed for: IE8
105
- (function(){
106
- if (!('Element' in global) || Element.prototype.addEventListener || !Object.defineProperty)
107
- return;
108
-
109
- // interface Event
110
-
111
- // PhaseType (const unsigned short)
112
- Event.CAPTURING_PHASE = 1;
113
- Event.AT_TARGET = 2;
114
- Event.BUBBLING_PHASE = 3;
115
-
116
- Object.defineProperties(Event.prototype, {
117
- CAPTURING_PHASE: { get: function() { return 1; } },
118
- AT_TARGET: { get: function() { return 2; } },
119
- BUBBLING_PHASE: { get: function() { return 3; } },
120
- target: {
121
- get: function() {
122
- return this.srcElement;
123
- }},
124
- currentTarget: {
125
- get: function() {
126
- return this._currentTarget;
127
- }},
128
- eventPhase: {
129
- get: function() {
130
- return (this.srcElement === this.currentTarget) ? Event.AT_TARGET : Event.BUBBLING_PHASE;
131
- }},
132
- bubbles: {
133
- get: function() {
134
- switch (this.type) {
135
- // Mouse
136
- case 'click':
137
- case 'dblclick':
138
- case 'mousedown':
139
- case 'mouseup':
140
- case 'mouseover':
141
- case 'mousemove':
142
- case 'mouseout':
143
- case 'mousewheel':
144
- // Keyboard
145
- case 'keydown':
146
- case 'keypress':
147
- case 'keyup':
148
- // Frame/Object
149
- case 'resize':
150
- case 'scroll':
151
- // Form
152
- case 'select':
153
- case 'change':
154
- case 'submit':
155
- case 'reset':
156
- return true;
157
- }
158
- return false;
159
- }},
160
- cancelable: {
161
- get: function() {
162
- switch (this.type) {
163
- // Mouse
164
- case 'click':
165
- case 'dblclick':
166
- case 'mousedown':
167
- case 'mouseup':
168
- case 'mouseover':
169
- case 'mouseout':
170
- case 'mousewheel':
171
- // Keyboard
172
- case 'keydown':
173
- case 'keypress':
174
- case 'keyup':
175
- // Form
176
- case 'submit':
177
- return true;
178
- }
179
- return false;
180
- }},
181
- timeStamp: {
182
- get: function() {
183
- return this._timeStamp;
184
- }},
185
- stopPropagation: {
186
- value: function() {
187
- this.cancelBubble = true;
188
- }},
189
- preventDefault: {
190
- value: function() {
191
- this.returnValue = false;
192
- }},
193
- defaultPrevented: {
194
- get: function() {
195
- return this.returnValue === false;
196
- }}
197
- });
198
-
199
- // interface EventTarget
200
-
201
- function addEventListener(type, listener, useCapture) {
202
- if (typeof listener !== 'function') return;
203
- if (type === 'DOMContentLoaded') type = 'load';
204
- var target = this;
205
- var f = function(e) {
206
- e._timeStamp = Date.now();
207
- e._currentTarget = target;
208
- listener.call(this, e);
209
- e._currentTarget = null;
210
- };
211
- this['_' + type + listener] = f;
212
- this.attachEvent('on' + type, f);
213
- }
214
-
215
- function removeEventListener(type, listener, useCapture) {
216
- if (typeof listener !== 'function') return;
217
- if (type === 'DOMContentLoaded') type = 'load';
218
- var f = this['_' + type + listener];
219
- if (f) {
220
- this.detachEvent('on' + type, f);
221
- this['_' + type + listener] = null;
222
- }
223
- }
224
-
225
- [Window, HTMLDocument, Element].forEach(function(o) {
226
- o.prototype.addEventListener = addEventListener;
227
- o.prototype.removeEventListener = removeEventListener;
228
- });
229
- }());
230
-
231
- // CustomEvent
232
- // https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent
233
- // Needed for: IE
234
- (function () {
235
- if ('CustomEvent' in global && typeof global.CustomEvent === "function")
236
- return;
237
- function CustomEvent ( event, params ) {
238
- params = params || { bubbles: false, cancelable: false, detail: undefined };
239
- var evt = document.createEvent( 'CustomEvent' );
240
- evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail );
241
- return evt;
242
- }
243
- CustomEvent.prototype = global.Event.prototype;
244
- global.CustomEvent = CustomEvent;
245
- })();
246
-
247
- // Shim for DOM Events for IE7-
248
- // http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html
249
- // Use addEvent(object, event, handler) instead of object.addEventListener(event, handler)
250
- window.addEvent = function(obj, type, fn) {
251
- if (obj.addEventListener) {
252
- obj.addEventListener(type, fn, false);
253
- } else if (obj.attachEvent) {
254
- obj["e" + type + fn] = fn;
255
- obj[type + fn] = function() {
256
- var e = window.event;
257
- e.currentTarget = obj;
258
- e.preventDefault = function() { e.returnValue = false; };
259
- e.stopPropagation = function() { e.cancelBubble = true; };
260
- e.target = e.srcElement;
261
- e.timeStamp = Date.now();
262
- obj["e" + type + fn].call(this, e);
263
- };
264
- obj.attachEvent("on" + type, obj[type + fn]);
265
- }
266
- };
267
-
268
- window.removeEvent = function(obj, type, fn) {
269
- if (obj.removeEventListener) {
270
- obj.removeEventListener(type, fn, false);
271
- } else if (obj.detachEvent) {
272
- obj.detachEvent("on" + type, obj[type + fn]);
273
- obj[type + fn] = null;
274
- obj["e" + type + fn] = null;
275
- }
276
- };
277
-
278
- // DOMTokenList interface and Element.classList / Element.relList
279
- // Needed for: IE9-
280
- // Use getClassList(elem) instead of elem.classList() if IE7- support is needed
281
- // Use getRelList(elem) instead of elem.relList() if IE7- support is needed
282
- (function() {
283
- function DOMTokenListShim(o, p) {
284
- function split(s) { return s.length ? s.split(/\s+/g) : []; }
285
-
286
- // NOTE: This does not exactly match the spec.
287
- function removeTokenFromString(token, string) {
288
- var tokens = split(string),
289
- index = tokens.indexOf(token);
290
- if (index !== -1) {
291
- tokens.splice(index, 1);
292
- }
293
- return tokens.join(' ');
294
- }
295
-
296
- Object.defineProperties(
297
- this,
298
- {
299
- length: {
300
- get: function() { return split(o[p]).length; }
301
- },
302
-
303
- item: {
304
- value: function(idx) {
305
- var tokens = split(o[p]);
306
- return 0 <= idx && idx < tokens.length ? tokens[idx] : null;
307
- }
308
- },
309
-
310
- contains: {
311
- value: function(token) {
312
- token = String(token);
313
- if (token.length === 0) { throw SyntaxError(); }
314
- if (/\s/.test(token)) { throw Error("InvalidCharacterError"); }
315
- var tokens = split(o[p]);
316
-
317
- return tokens.indexOf(token) !== -1;
318
- }
319
- },
320
-
321
- add: {
322
- value: function(/*tokens...*/) {
323
- var tokens = Array.prototype.slice.call(arguments).map(String);
324
- if (tokens.some(function(token) { return token.length === 0; })) {
325
- throw SyntaxError();
326
- }
327
- if (tokens.some(function(token) { return (/\s/).test(token); })) {
328
- throw Error("InvalidCharacterError");
329
- }
330
-
331
- try {
332
- var underlying_string = o[p];
333
- var token_list = split(underlying_string);
334
- tokens = tokens.filter(function(token) { return token_list.indexOf(token) === -1; });
335
- if (tokens.length === 0) {
336
- return;
337
- }
338
- if (underlying_string.length !== 0 && !(/\s$/).test(underlying_string)) {
339
- underlying_string += ' ';
340
- }
341
- underlying_string += tokens.join(' ');
342
- o[p] = underlying_string;
343
- } finally {
344
- var length = split(o[p]).length;
345
- if (this.length !== length) { this.length = length; }
346
- }
347
- }
348
- },
349
-
350
- remove: {
351
- value: function(/*tokens...*/) {
352
- var tokens = Array.prototype.slice.call(arguments).map(String);
353
- if (tokens.some(function(token) { return token.length === 0; })) {
354
- throw SyntaxError();
355
- }
356
- if (tokens.some(function(token) { return (/\s/).test(token); })) {
357
- throw Error("InvalidCharacterError");
358
- }
359
-
360
- try {
361
- var underlying_string = o[p];
362
- tokens.forEach(function(token) {
363
- underlying_string = removeTokenFromString(token, underlying_string);
364
- });
365
- o[p] = underlying_string;
366
- } finally {
367
- var length = split(o[p]).length;
368
- if (this.length !== length) { this.length = length; }
369
- }
370
- }
371
- },
372
-
373
- toggle: {
374
- value: function(token/*, force*/) {
375
- var force = arguments[1];
376
- try {
377
- token = String(token);
378
- if (token.length === 0) { throw SyntaxError(); }
379
- if (/\s/.test(token)) { throw Error("InvalidCharacterError"); }
380
- var tokens = split(o[p]),
381
- index = tokens.indexOf(token);
382
-
383
- if (index !== -1 && (!force || force === (void 0))) {
384
- o[p] = removeTokenFromString(token, o[p]);
385
- return false;
386
- }
387
- if (index !== -1 && force) {
388
- return true;
389
- }
390
- var underlying_string = o[p];
391
- if (underlying_string.length !== 0 && !/\s$/.test(underlying_string)) {
392
- underlying_string += ' ';
393
- }
394
- underlying_string += token;
395
- o[p] = underlying_string;
396
- return true;
397
- } finally {
398
- var length = split(o[p]).length;
399
- if (this.length !== length) { this.length = length; }
400
- }
401
- }
402
- },
403
-
404
- toString: {
405
- value: function() {
406
- return o[p];
407
- }
408
- }
409
- });
410
- if (!('length' in this)) {
411
- // In case getters are not supported
412
- this.length = split(o[p]).length;
413
- } else {
414
- // If they are, shim in index getters (up to 100)
415
- for (var i = 0; i < 100; ++i) {
416
- Object.defineProperty(this, String(i), {
417
- get: (function(n) { return function() { return this.item(n); }; }(i))
418
- });
419
- }
420
- }
421
- }
422
-
423
- function addToElementPrototype(p, f) {
424
- if ('Element' in global && Element.prototype && Object.defineProperty) {
425
- Object.defineProperty(Element.prototype, p, { get: f });
426
- }
427
- }
428
-
429
- // HTML - https://html.spec.whatwg.org
430
- // Element.classList
431
- if ('classList' in document.createElement('span')) {
432
- window.getClassList = function(elem) { return elem.classList; };
433
- } else {
434
- window.getClassList = function(elem) { return new DOMTokenListShim(elem, 'className'); };
435
- addToElementPrototype('classList', function() { return new DOMTokenListShim(this, 'className'); } );
436
- }
437
-
438
- // HTML - https://html.spec.whatwg.org
439
- // HTMLAnchorElement.relList
440
- // HTMLLinkElement.relList
441
- if ('relList' in document.createElement('link')) {
442
- window.getRelList = function(elem) { return elem.relList; };
443
- } else {
444
- window.getRelList = function(elem) { return new DOMTokenListShim(elem, 'rel'); };
445
- addToElementPrototype('relList', function() { return new DOMTokenListShim(this, 'rel'); } );
446
- }
447
-
448
- // Add second argument to native DOMTokenList.toggle() if necessary
449
- (function() {
450
- if (!('DOMTokenList' in global)) return;
451
- var e = document.createElement('span');
452
- if (!('classList' in e)) return;
453
- e.classList.toggle('x', false);
454
- if (!e.classList.contains('x')) return;
455
- global.DOMTokenList.prototype.toggle = function toggle(token/*, force*/) {
456
- var force = arguments[1];
457
- if (force === undefined) {
458
- var add = !this.contains(token);
459
- this[add ? 'add' : 'remove'](token);
460
- return add;
461
- }
462
- force = !!force;
463
- this[force ? 'add' : 'remove'](token);
464
- return force;
465
- };
466
- }());
467
-
468
-
469
- // DOM - Interface NonDocumentTypeChildNode
470
- // Interface NonDocumentTypeChildNode
471
- // previousElementSibling / nextElementSibling - for IE8
472
-
473
- if (!('previousElementSibling' in document.documentElement)) {
474
- addToElementPrototype('previousElementSibling', function() {
475
- var n = this.previousSibling;
476
- while (n && n.nodeType !== Node.ELEMENT_NODE)
477
- n = n.previousSibling;
478
- return n;
479
- });
480
- }
481
-
482
- if (!('nextElementSibling' in document.documentElement)) {
483
- addToElementPrototype('nextElementSibling', function() {
484
- var n = this.nextSibling;
485
- while (n && n.nodeType !== Node.ELEMENT_NODE)
486
- n = n.nextSibling;
487
- return n;
488
- });
489
- }
490
- }());
491
-
492
- // Element.matches
493
- // https://developer.mozilla.org/en/docs/Web/API/Element/matches
494
- // Needed for: IE, Firefox 3.6, early Webkit and Opera 15.0
495
- // Use msMatchesSelector(selector) for IE
496
- // Use oMatchesSelector(selector) for Opera 15.0
497
- // Use mozMatchesSelector(selector) for Firefox 3.6
498
- // Use webkitMatchesSelector(selector) for early Webkit
499
- // Use polyfill if no matches() support, but querySelectorAll() support
500
- if ('Element' in global && !Element.prototype.matches) {
501
- if (Element.prototype.msMatchesSelector) {
502
- Element.prototype.matches = Element.prototype.msMatchesSelector;
503
- } else if (Element.prototype.oMatchesSelector) {
504
- Element.prototype.matches = Element.prototype.oMatchesSelector;
505
- } else if (Element.prototype.mozMatchesSelector) {
506
- Element.prototype.matches = Element.prototype.mozMatchesSelector;
507
- } else if (Element.prototype.webkitMatchesSelector) {
508
- Element.prototype.matches = Element.prototype.webkitMatchesSelector;
509
- } else if (document.querySelectorAll) {
510
- Element.prototype.matches = function matches(selector) {
511
- var matches = (this.document || this.ownerDocument).querySelectorAll(selector),
512
- i = matches.length;
513
- while (--i >= 0 && matches.item(i) !== this) {}
514
- return i > -1;
515
- };
516
- }
517
- }
518
-
519
- // Element.closest
520
- // https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
521
- if (window.Element && !Element.prototype.closest) {
522
- Element.prototype.closest = function(s) {
523
- var matches = (this.document || this.ownerDocument).querySelectorAll(s),
524
- i,
525
- el = this;
526
- do {
527
- i = matches.length;
528
- while (--i >= 0 && matches.item(i) !== el) {};
529
- } while ((i < 0) && (el = el.parentElement));
530
- return el;
531
- };
532
- }
533
-
534
- function mixin(o, ps) {
535
- if (!o) return;
536
- Object.keys(ps).forEach(function(p) {
537
- if ((p in o) || (p in o.prototype)) return;
538
- try {
539
- Object.defineProperty(
540
- o.prototype,
541
- p,
542
- Object.getOwnPropertyDescriptor(ps, p)
543
- );
544
- } catch (ex) {
545
- // Throws in IE8; just copy it
546
- o[p] = ps[p];
547
- }
548
- });
549
- }
550
-
551
- // Mixin ParentNode
552
- // https://dom.spec.whatwg.org/#interface-parentnode
553
-
554
- function convertNodesIntoANode(nodes) {
555
- var node = null;
556
- nodes = nodes.map(function(node) {
557
- return !(node instanceof Node) ? document.createTextNode(node) : node;
558
- });
559
- if (nodes.length === 1) {
560
- node = nodes[0];
561
- } else {
562
- node = document.createDocumentFragment();
563
- nodes.forEach(function(n) { node.appendChild(n); });
564
- }
565
- return node;
566
- }
567
-
568
- var ParentNode = {
569
- prepend: function(/*...nodes*/) {
570
- var nodes = [].slice.call(arguments);
571
- nodes = convertNodesIntoANode(nodes);
572
- this.insertBefore(nodes, this.firstChild);
573
- },
574
- append: function(/*...nodes*/) {
575
- var nodes = [].slice.call(arguments);
576
- nodes = convertNodesIntoANode(nodes);
577
- this.appendChild(nodes);
578
- }
579
- };
580
-
581
- mixin(global.Document || global.HTMLDocument, ParentNode); // HTMLDocument for IE8
582
- mixin(global.DocumentFragment, ParentNode);
583
- mixin(global.Element, ParentNode);
584
-
585
- // Mixin ChildNode
586
- // https://dom.spec.whatwg.org/#interface-childnode
587
-
588
- var ChildNode = {
589
- before: function(/*...nodes*/) {
590
- var nodes = [].slice.call(arguments);
591
- var parent = this.parentNode;
592
- if (!parent) return;
593
- var viablePreviousSibling = this.previousSibling;
594
- while (nodes.indexOf(viablePreviousSibling) !== -1)
595
- viablePreviousSibling = viablePreviousSibling.previousSibling;
596
- var node = convertNodesIntoANode(nodes);
597
- parent.insertBefore(node, viablePreviousSibling ?
598
- viablePreviousSibling.nextSibling : parent.firstChild);
599
- },
600
- after: function(/*...nodes*/) {
601
- var nodes = [].slice.call(arguments);
602
- var parent = this.parentNode;
603
- if (!parent) return;
604
- var viableNextSibling = this.nextSibling;
605
- while (nodes.indexOf(viableNextSibling) !== -1)
606
- viableNextSibling = viableNextSibling.nextSibling;
607
- var node = convertNodesIntoANode(nodes);
608
- parent.insertBefore(node, viableNextSibling);
609
- },
610
- replaceWith: function(/*...nodes*/) {
611
- var nodes = [].slice.call(arguments);
612
- var parent = this.parentNode;
613
- if (!parent) return;
614
- var viableNextSibling = this.nextSibling;
615
- while (nodes.indexOf(viableNextSibling) !== -1)
616
- viableNextSibling = viableNextSibling.nextSibling;
617
- var node = convertNodesIntoANode(nodes);
618
-
619
- if (this.parentNode === parent)
620
- parent.replaceChild(node, this);
621
- else
622
- parent.insertBefore(node, viableNextSibling);
623
- },
624
- remove: function() {
625
- if (!this.parentNode) return;
626
- this.parentNode.removeChild(this);
627
- }
628
- };
629
-
630
- mixin(global.DocumentType, ChildNode);
631
- mixin(global.Element, ChildNode);
632
- mixin(global.CharacterData, ChildNode);
633
-
634
- }(self));