Class MutationObserver


  • @JsType(isNative=true,
            namespace="<global>")
    public final class MutationObserver
    extends Object
    Provides the ability to watch for changes being made to the DOM tree.
    Author:
    Andrea "Stock" Stocchero
    • Constructor Detail

      • MutationObserver

        public MutationObserver​(MutationObserver.MutationObserverCallback callback)
        Creates and returns a new mutation observer which will invoke a specified callback function when DOM changes occur.
        Parameters:
        callback - a function which will be called on each DOM change that qualifies given the targeted node or subtree and options
    • Method Detail

      • disconnect

        public void disconnect()
        Stops the mutation observer instance from receiving further notifications until and unless observe(BaseNode) is called again.
      • observe

        public void observe​(BaseNode target,
                            MutationObserverInit options)
        Configures the mutation observer to begin receiving notifications through its callback function when DOM changes matching the given options occur.
        Parameters:
        target - a DOM node within the DOM tree to watch for changes, or to be the root of a subtree of nodes to be watched
        options - initialization object providing options that describe what DOM mutations should be reported to the observer's callback
      • observe

        public void observe​(BaseNode target)
        Configures the mutation observer to begin receiving notifications through its callback function when DOM changes matching the given options occur.
        Parameters:
        target - a DOM node within the DOM tree to watch for changes, or to be the root of a subtree of nodes to be watched
      • takeRecords

        public MutationRecord[] takeRecords()
        Removes all pending notifications from the mutation observer's notification queue and returns them in a new array of mutation record objects.
        Returns:
        all pending notifications from the mutation observer's notification queue