You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+5-2
Original file line number
Diff line number
Diff line change
@@ -148,9 +148,12 @@ If a selector string is passed instead, it will be used to find the element.
148
148
If you want to observe the entire document, you can pass `document.body`
149
149
150
150
The `options` parameter is optional and will be passed to the MutationObserver that is used internally.
151
-
The default options are `{ childList: true, subtree: true }` - you may see the [MutationObserver.observe() documentation](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver/observe#options) for more information and a list of options.
152
-
For example, if you want to trigger the listeners when certain attributes change, pass `{ attributes: true, attributeFilter: ["class", "data-my-attribute"] }`
151
+
The MutationObserver options present by default are `{ childList: true, subtree: true }` - you may see the [MutationObserver.observe() documentation](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver/observe#options) for more information and a list of options.
152
+
For example, if you want to trigger the listeners when certain attributes change, pass `{ attributeFilter: ["class", "data-my-attribute"] }`
153
+
153
154
Additionally, there are the following extra options:
155
+
-`disableOnNoListeners` - whether to disable the SelectorObserver when there are no listeners left (defaults to false)
156
+
-`enableOnAddListener` - whether to enable the SelectorObserver when a new listener is added (defaults to true)
154
157
-`defaultDebounce` - if set to a number, this debounce will be applied to every listener that doesn't have a custom debounce set (defaults to 0)
155
158
156
159
⚠️ Make sure to call `enable()` to actually start observing. This will need to be done after the DOM has loaded (when using `@run-at document-end` or after `DOMContentLoaded` has fired) **and** as soon as the `baseElement` or `baseElementSelector` is available.
* Creates a new SelectorObserver that will observe the children of the given base element selector for changes (only creation and deletion of elements by default)
40
45
* @param baseElementSelector The selector of the element to observe
41
46
* @param options Fine-tune what triggers the MutationObserver's checking function - `subtree` and `childList` are set to true by default
* Creates a new SelectorObserver that will observe the children of the given base element for changes (only creation and deletion of elements by default)
46
51
* @param baseElement The element to observe
@@ -53,10 +58,24 @@ export class SelectorObserver {
0 commit comments