// removes refs from the tracker, and reports removed external refs
        private void RemoveReference(DomNode owner, AttributeInfo attributeInfo, DomNode target)
        {
            List <Pair <DomNode, AttributeInfo> > referenceList;

            if (m_nodeReferenceLists.TryGetValue(target, out referenceList))
            {
                referenceList.Remove(new Pair <DomNode, AttributeInfo>(owner, attributeInfo));
                if (referenceList.Count == 0)
                {
                    m_nodeReferenceLists.Remove(target);
                }
            }

            // if target's root isn't the context's root, then it's an external reference
            //  that is being removed.
            DomNode targetRoot = target.GetRoot();

            if (DomNode != targetRoot)
            {
                ReferenceEventArgs e = new ReferenceEventArgs(owner, attributeInfo, target);
                OnExternalReferenceRemoved(e);
                ExternalReferenceRemoved.Raise(this, e);
            }
        }
 /// <summary>
 /// Performs actions after a reference to an external DOM node is removed</summary>
 /// <param name="e">Event args describing reference</param>
 protected virtual void OnExternalReferenceRemoved(ReferenceEventArgs e)
 {
     ExternalReferenceRemoved.Raise(this, e);
 }