Skip to content

Avoid StateError in _parseStyles: check elements before using .single - #410

Open
paulob3j wants to merge 4 commits into
justkawal:mainfrom
paulob3j:fix-parse-no-element
Open

paulob3j wants to merge 4 commits into
justkawal:mainfrom
paulob3j:fix-parse-no-element

Conversation

@paulob3j

@paulob3j paulob3j commented Jun 8, 2025

Copy link
Copy Markdown

🐞 What is the bug?
The method _parseStyles throws a StateError: No element when it tries to call .single on the result of node.findElements(elementName). This happens when the XML element is missing or duplicated, causing the .single call to fail.

🔧 What was changed?
Replaced the unsafe usage of .single with a check that ensures exactly one element exists before accessing it. If not, the element is safely set to null.

Issues:

#374

@paulob3j
paulob3j requested a review from justkawal as a code owner June 8, 2025 04:45
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

Successfully merging this pull request may close these issues.

3 participants