Skip to content

Commit

Permalink
fix: proceed applying part to next level
Browse files Browse the repository at this point in the history
Regardless of current element already having a part attribute.
  • Loading branch information
fterra-encora committed Oct 9, 2023
1 parent ae3a94d commit 6af4f2c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions frontend/src/helpers/CustomDirectives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ export const masking = (shadowSelector: string) => (el: any, binding: any) => {
const setPart = (nodes: HTMLCollection, currentLevel: number, maxLevel: number) => {
for (const node of nodes) {
if (node.nodeType === Node.ELEMENT_NODE) {
if (node.getAttribute('part')) continue

const partValues = [node.tagName.toLowerCase()]
if (node.className) {
partValues.push(node.className)
if (!node.getAttribute('part')) {
const partValues = [node.tagName.toLowerCase()]
if (node.className) {
partValues.push(node.className)
}
node.setAttribute('part', partValues.join(' '))
}
node.setAttribute('part', partValues.join(' '))

if (currentLevel < maxLevel) {
setPart(node.children, currentLevel + 1, maxLevel)
}
Expand Down

0 comments on commit 6af4f2c

Please sign in to comment.