Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Remove MutationObserver filtering of script, style, and template elem…
Browse files Browse the repository at this point in the history
…ents

Fixes #72
  • Loading branch information
dfreedm committed Oct 9, 2013
1 parent fcbb7df commit 013d2b2
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/Observer.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,16 +243,6 @@ function watchRoot(root) {
}
}

function filter(inNode) {
switch (inNode.localName) {
case 'style':
case 'script':
case 'template':
case undefined:
return true;
}
}

function handler(mutations) {
//
if (logFlags.dom) {
Expand All @@ -275,7 +265,7 @@ function handler(mutations) {
if (mx.type === 'childList') {
forEach(mx.addedNodes, function(n) {
//logFlags.dom && console.log(n.localName);
if (filter(n)) {

This comment has been minimized.

Copy link
@sorvell

sorvell Oct 10, 2013

Contributor

The minimal fix here (and likewise for remove) would seem to be:

if (filter(n)) {
  added(n);
} else {
  addedNode(n);
if (!n.localName) {
return;
}
// nodes added may need lifecycle management
Expand All @@ -284,7 +274,7 @@ function handler(mutations) {
// removed nodes may need lifecycle management
forEach(mx.removedNodes, function(n) {
//logFlags.dom && console.log(n.localName);
if (filter(n)) {
if (!n.localName) {
return;
}
removedNode(n);
Expand Down

1 comment on commit 013d2b2

@sjmiles
Copy link
Contributor

@sjmiles sjmiles commented on 013d2b2 Oct 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of the role of the filter is to avoid walking into nodes of those types, I'm not sure just eliminating the filter is the right course of action here.

Please sign in to comment.