Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError when the first node is "decl" type #23

Open
erickskrauch opened this issue Mar 26, 2021 · 0 comments
Open

TypeError when the first node is "decl" type #23

erickskrauch opened this issue Mar 26, 2021 · 0 comments

Comments

@erickskrauch
Copy link

This condition fails in the case when the first element has the type decl. This is a common situation when the CSS is written in SCSS/LESS.

if (item.type === 'rule') {
tree[idx] = {
rule: item,
nodes: [],
ltrRule: cloneItem(item),
ltrNodes: [],
rtlRule: cloneItem(item),
rtlNodes: [],
isBiDi: false
};
currentIdx = idx;
idx += 1;
} else if (item.type === 'decl') {
tree[currentIdx].nodes.push(item);
tree[currentIdx].ltrNodes.push(cloneItem(item));
tree[currentIdx].rtlNodes.push(cloneItem(item));
}

Can be easily fixed by this condition fix (highlighted part):
possible fix

But it seems a bit ugly. Will be glad to have more stable and right fix.

erickskrauch added a commit to erickskrauch/postcss-bidirection that referenced this issue Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant