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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 * Filter type as a string, e.g. "blocking". | 75 * Filter type as a string, e.g. "blocking". |
76 * @type {string} | 76 * @type {string} |
77 */ | 77 */ |
78 get type() | 78 get type() |
79 { | 79 { |
80 throw new Error("Please define filter type in the subclass"); | 80 throw new Error("Please define filter type in the subclass"); |
81 }, | 81 }, |
82 | 82 |
83 /** | 83 /** |
84 * Subscriptions to which this filter belongs. | 84 * Subscriptions to which this filter belongs. |
85 * @type {(Subscription|Set.<Subscription>)?} | 85 * @type {?(Subscription|Set.<Subscription>)} |
86 * @private | 86 * @private |
87 */ | 87 */ |
88 _subscriptions: null, | 88 _subscriptions: null, |
89 | 89 |
90 /** | 90 /** |
91 * Whether the filter's subscriptions have already been added to the filter. | 91 * Whether the filter's subscriptions have already been added to the filter. |
92 * @type {boolean} | 92 * @type {boolean} |
93 * @package | 93 * @package |
94 */ | 94 */ |
95 get subscriptionsAdded() | 95 get subscriptionsAdded() |
96 { | 96 { |
97 return this.hasOwnProperty("_subscriptions"); | 97 return this.hasOwnProperty("_subscriptions"); |
98 }, | 98 }, |
99 set subscriptionsAdded(value) | 99 set subscriptionsAdded(value) |
100 { | 100 { |
101 // Once set to true, the cannot be set back to false even if all | 101 // Once set to true, this cannot be set back to false even if all |
hub
2018/11/10 04:33:21
typo.
| |
102 // subscriptions are removed. | 102 // subscriptions are removed. |
103 if (value) | 103 if (value) |
104 this._subscriptions = this._subscriptions; | 104 this._subscriptions = this._subscriptions; |
hub
2018/11/10 04:33:21
I don't understand what's happening here. This ass
Manish Jethani
2018/11/15 22:58:52
Not really, it sets the property on the this objec
hub
2018/11/16 17:04:39
Acknowledged.
| |
105 }, | 105 }, |
106 | 106 |
107 /** | 107 /** |
108 * Yields subscriptions to which the filter belongs. | 108 * Yields subscriptions to which the filter belongs. |
109 * @yields {Subscription} | 109 * @yields {Subscription} |
110 * @package | |
110 */ | 111 */ |
111 *subscriptions() | 112 *subscriptions() |
112 { | 113 { |
113 if (this._subscriptions) | 114 if (this._subscriptions) |
114 { | 115 { |
115 if (this._subscriptions instanceof Set) | 116 if (this._subscriptions instanceof Set) |
116 yield* this._subscriptions; | 117 yield* this._subscriptions; |
117 else | 118 else |
118 yield this._subscriptions; | 119 yield this._subscriptions; |
119 } | 120 } |
120 }, | 121 }, |
121 | 122 |
122 /** | 123 /** |
123 * The number of subscriptions to which the filter belongs. | 124 * The number of subscriptions to which the filter belongs. |
124 * @type {number} | 125 * @type {number} |
126 * @package | |
125 */ | 127 */ |
126 get subscriptionCount() | 128 get subscriptionCount() |
127 { | 129 { |
128 if (this._subscriptions instanceof Set) | 130 if (this._subscriptions instanceof Set) |
129 return this._subscriptions.size; | 131 return this._subscriptions.size; |
130 | 132 |
131 return this._subscriptions ? 1 : 0; | 133 return this._subscriptions ? 1 : 0; |
132 }, | 134 }, |
133 | 135 |
134 /** | 136 /** |
135 * Adds a subscription to the set of subscriptions to which the filter | 137 * Adds a subscription to the set of subscriptions to which the filter |
136 * belongs. | 138 * belongs. |
137 * @param {Subscription} subscription | 139 * @param {Subscription} subscription |
140 * @package | |
138 */ | 141 */ |
139 addSubscription(subscription) | 142 addSubscription(subscription) |
140 { | 143 { |
141 // Since we use truthy checks in our logic, we must avoid adding a | 144 // Since we use truthy checks in our logic, we must avoid adding a |
142 // subscription that isn't a non-null object. | 145 // subscription that isn't a non-null object. |
143 if (subscription === null || typeof subscription != "object") | 146 if (subscription === null || typeof subscription != "object") |
144 return; | 147 return; |
145 | 148 |
146 if (this._subscriptions) | 149 if (this._subscriptions) |
147 { | 150 { |
148 if (this._subscriptions instanceof Set) | 151 if (this._subscriptions instanceof Set) |
149 this._subscriptions.add(subscription); | 152 this._subscriptions.add(subscription); |
150 else if (subscription != this._subscriptions) | 153 else if (subscription != this._subscriptions) |
151 this._subscriptions = new Set([this._subscriptions, subscription]); | 154 this._subscriptions = new Set([this._subscriptions, subscription]); |
152 } | 155 } |
153 else | 156 else |
154 { | 157 { |
155 this._subscriptions = subscription; | 158 this._subscriptions = subscription; |
156 } | 159 } |
157 }, | 160 }, |
158 | 161 |
159 /** | 162 /** |
160 * Removes a subscription from the set of subscriptions to which the filter | 163 * Removes a subscription from the set of subscriptions to which the filter |
161 * belongs. | 164 * belongs. |
162 * @param {Subscription} subscription | 165 * @param {Subscription} subscription |
166 * @package | |
163 */ | 167 */ |
164 removeSubscription(subscription) | 168 removeSubscription(subscription) |
165 { | 169 { |
166 if (this._subscriptions) | 170 if (this._subscriptions) |
167 { | 171 { |
168 if (this._subscriptions instanceof Set) | 172 if (this._subscriptions instanceof Set) |
169 { | 173 { |
170 this._subscriptions.delete(subscription); | 174 this._subscriptions.delete(subscription); |
171 | 175 |
172 if (this._subscriptions.size == 1) | 176 if (this._subscriptions.size == 1) |
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1370 | 1374 |
1371 /** | 1375 /** |
1372 * Script that should be executed | 1376 * Script that should be executed |
1373 * @type {string} | 1377 * @type {string} |
1374 */ | 1378 */ |
1375 get script() | 1379 get script() |
1376 { | 1380 { |
1377 return this.body; | 1381 return this.body; |
1378 } | 1382 } |
1379 }); | 1383 }); |
LEFT | RIGHT |