|
1 |
| -import DOMException from '../exception/DOMException.js'; |
2 | 1 | import * as PropertySymbol from '../PropertySymbol.js';
|
3 | 2 | import INode from '../nodes/node/INode.js';
|
4 | 3 | import Node from '../nodes/node/Node.js';
|
@@ -34,13 +33,50 @@ export default class MutationObserver {
|
34 | 33 | */
|
35 | 34 | public observe(target: INode, options: IMutationObserverInit): void {
|
36 | 35 | if (!target) {
|
37 |
| - throw new DOMException( |
| 36 | + throw new TypeError( |
38 | 37 | `Failed to execute 'observe' on 'MutationObserver': The first parameter "target" should be of type "Node".`
|
39 | 38 | );
|
40 | 39 | }
|
41 | 40 |
|
| 41 | + if (options && (options.attributeFilter || options.attributeOldValue)) { |
| 42 | + if (options.attributes === undefined) { |
| 43 | + options = Object.assign({}, options, { |
| 44 | + attributes: true, |
| 45 | + attributeFilter: options.attributeFilter, |
| 46 | + attributeOldValue: options.attributeOldValue |
| 47 | + }); |
| 48 | + } |
| 49 | + |
| 50 | + if (!options.attributes && options.attributeOldValue) { |
| 51 | + throw new TypeError( |
| 52 | + `Failed to execute 'observe' on 'MutationObserver': The options object may only set 'attributeOldValue' to true when 'attributes' is true or not present.` |
| 53 | + ); |
| 54 | + } |
| 55 | + |
| 56 | + if (!options.attributes && options.attributeFilter) { |
| 57 | + throw new TypeError( |
| 58 | + `Failed to execute 'observe' on 'MutationObserver': The options object may only set 'attributeFilter' when 'attributes' is true or not present.` |
| 59 | + ); |
| 60 | + } |
| 61 | + } |
| 62 | + |
| 63 | + if (options && options.characterDataOldValue) { |
| 64 | + if (options.characterData === undefined) { |
| 65 | + options = Object.assign({}, options, { |
| 66 | + characterData: true, |
| 67 | + characterDataOldValue: options.characterDataOldValue |
| 68 | + }); |
| 69 | + } |
| 70 | + |
| 71 | + if (!options.characterData && options.characterDataOldValue) { |
| 72 | + throw new TypeError( |
| 73 | + `Failed to execute 'observe' on 'MutationObserver': The options object may only set 'characterDataOldValue' to true when 'characterData' is true or not present.` |
| 74 | + ); |
| 75 | + } |
| 76 | + } |
| 77 | + |
42 | 78 | if (!options || (!options.childList && !options.attributes && !options.characterData)) {
|
43 |
| - throw new DOMException( |
| 79 | + throw new TypeError( |
44 | 80 | `Failed to execute 'observe' on 'MutationObserver': The options object must set at least one of 'attributes', 'characterData', or 'childList' to true.`
|
45 | 81 | );
|
46 | 82 | }
|
|
0 commit comments