Created
January 13, 2022 21:10
-
-
Save jameswomack/7b3d858c91c65c8b32bfbc6eb8dafe42 to your computer and use it in GitHub Desktop.
using the for loop paradigm to drill down to a matching shadowRoot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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