Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-present eyeo GmbH | 3 * Copyright (C) 2006-present eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 20 matching lines...) Expand all Loading... | |
31 { | 31 { |
32 let {children} = node.parentNode; | 32 let {children} = node.parentNode; |
33 for (let i = 0; i < children.length; i++) | 33 for (let i = 0; i < children.length; i++) |
34 if (children[i] == node) | 34 if (children[i] == node) |
35 return i + 1; | 35 return i + 1; |
36 return 0; | 36 return 0; |
37 } | 37 } |
38 | 38 |
39 function getCachedPropertyValue(object, name, defaultValueFunc = () => {}) | 39 function getCachedPropertyValue(object, name, defaultValueFunc = () => {}) |
40 { | 40 { |
41 if (!(name in object)) | 41 let value = object[name]; |
42 Object.defineProperty(object, name, {value: defaultValueFunc()}); | 42 if (value === undefined) |
43 return object[name]; | 43 { |
hub
2018/03/07 23:11:30
here I would rather do something like:
let value
Manish Jethani
2018/03/08 15:29:58
Thanks, this is a good idea.
Done.
(I'm using st
| |
44 value = defaultValueFunc(); | |
45 Object.defineProperty(object, name, {value}); | |
46 } | |
47 return value; | |
44 } | 48 } |
45 | 49 |
46 function makeSelector(node, selector) | 50 function makeSelector(node, selector) |
47 { | 51 { |
48 if (node == null) | 52 if (node == null) |
49 return null; | 53 return null; |
50 if (!node.parentElement) | 54 if (!node.parentElement) |
51 { | 55 { |
52 let newSelector = ":root"; | 56 let newSelector = ":root"; |
53 if (selector) | 57 if (selector) |
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
834 characterData: shouldObserveCharacterData(this.patterns), | 838 characterData: shouldObserveCharacterData(this.patterns), |
835 subtree: true | 839 subtree: true |
836 } | 840 } |
837 ); | 841 ); |
838 this.document.addEventListener("load", this.onLoad.bind(this), true); | 842 this.document.addEventListener("load", this.onLoad.bind(this), true); |
839 } | 843 } |
840 } | 844 } |
841 }; | 845 }; |
842 | 846 |
843 exports.ElemHideEmulation = ElemHideEmulation; | 847 exports.ElemHideEmulation = ElemHideEmulation; |
LEFT | RIGHT |