Returning to the original list of options, DOMNodeRemovedFromDocument
will fire in capture phase for descendants of removed elements.
The event isn't implemented in FF, though, so perhaps a moot point.
var outer = document.getElementById('outer'),
inner = document.getElementById('inner');
inner.addEventListener('DOMNodeRemovedFromDocument', function (e) {
/* this will be executed for this node and each child if it or
its parent is removed, replaced, or outer.innerHTML is assigned */
}, true);
Additionally, the callback will be executed if one of inner's children
is removed or replaced, or if it or one of its children's innerHTML is
assigned *usually*. The catch here is that Chrome 10.0 and Safari 5
don't execute it if a child that contains only text has its innerHTML
assigned. Opera does the right thing here. If the text is replaced
via replaceChild(document.createTextNode('blah'), ...firstChild), then
Chrome, Safari, and Opera execute the callback.
WebKit bug here: https://bugs.webkit.org/show_bug.cgi?id=56706
FYI,
L
On Mar 18, 2011, at 3:58 AM, Diego Perini wrote:
On Fri, Mar 18, 2011 at 3:13 AM, Matt Kruse
<[email protected]> wrote:
On Mar 17, 5:17 pm, Diego Perini <[email protected]> wrote:
This (3) seems to me the best solution but use
"compareDocumentPosition()" method instead.
I just learned of this method today. Very handy!
maybe you could use method 2 and "matchesSelector()" to avoid
using an expensive
universal "*" selector if you need to match an object reference
with a
selector string.
Is there browser support for this? I see that mozMoatchesSelector()
and webkitMatchesSelector() exist. I guess I need to do some browser
testing...
Yes, "matchesSelector()" is supported in all new browsers even in IE9.
Naming is a bit different in each implementation:
webkitMatchesSelector (Webkit)
mozMatchesSelector (Mozilla)
msMatchesSelector (MS)
matchesSelector (W3C)
--
Diego
Matt Kruse
--
To view archived discussions from the original JSMentors Mailman
list: http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]
--
To view archived discussions from the original JSMentors Mailman
list: http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]