Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jameswomack
Created January 13, 2022 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jameswomack/7b3d858c91c65c8b32bfbc6eb8dafe42 to your computer and use it in GitHub Desktop.
Save jameswomack/7b3d858c91c65c8b32bfbc6eb8dafe42 to your computer and use it in GitHub Desktop.
using the for loop paradigm to drill down to a matching shadowRoot
function updateState (state) {
return console.dir(state);
}
const thaNode = {};
const host = {
shadowRoot: thaNode
};
const detail = {
host: {
parentNode: {
parentNode: thaNode
}
},
action: {
payload: {
error: new Error('danger bill roberson')
}
}
};
for (
let currentElement = detail.host;
currentElement;
currentElement = currentElement.parentNode
) {
if (currentElement === host.shadowRoot)
updateState({error: detail.action.payload.error});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment