                 # internally, so we only want to emit instructions if there
                 # is a parent element pointer, meaning this CSSStyleDeclaration
                 # belongs to an element.
-                if this._parentElement
+                if this._parentElement && this._parentElement._attachedToDocument
                     browser.emit 'DOMStyleChanged',
                         target : this._parentElement
                         attribute : attr

    #
    # var oldChild = node.removeChild(child);
    adviseMethod html.Node, 'removeChild', (parent, args, rv) ->
        elem = args[0]
        # Note: Unlike DOM, we only emit DOMNodeRemovedFromDocument on the root
        # of the removed subtree.
        if parent._attachedToDocument
            browser.emit 'DOMNodeRemovedFromDocument',
                target : elem
                relatedNode : parent

        # Note: unlike the DOM, we only emit DOMNodeInsertedIntoDocument
        # on the root of a removed subtree, meaning the handler should check
        # to see if it has children.
        if parent._attachedToDocument && elem.nodeType != 11
            browser.emit 'DOMNodeInsertedIntoDocument',
                target : elem
                relatedNode : parent
