openscd / open-scd

A substation configuration description editor for projects using SCL IEC 61850-6 Edition 2 or greater
https://openscd.github.io
Apache License 2.0
101 stars 38 forks source link

SyntaxError at src/editors/cleanup/control-blocks-container.js #1145

Closed juancho0202 closed 1 year ago

juancho0202 commented 1 year ago

Describe the bug The clean up plugin seems to struggle with some particular LN selectors. The following stack trace was caught by Elastic monitoring:

Unhandled promise rejection: SyntaxError: Failed to execute 'querySelector' on 'Element': 'DataSet[name=Relay_FIELDAApplication/LLN0$BR$A_BRCB_23]' is not a valid selector.
at <anonymous> (src/editors/cleanup/control-blocks-container.js:181:36)
at renderUnreferencedControls (src/editors/cleanup/control-blocks-container.js:178:129)
at render (src/editors/cleanup/control-blocks-container.js:224:36)
at update (_snowpack/pkg/common/lit-element-d8235cfe.js:1749:37)
at performUpdate (_snowpack/pkg/common/lit-element-d8235cfe.js:951:22)
at _enqueueUpdate (_snowpack/pkg/common/lit-element-d8235cfe.js:904:29)
juancho0202 commented 1 year ago

Unfortunately the monitoring tool doesn't catch the particular SCL file that was being used by the user at the time the error was thrown so it may be tricky to reproduce.

danyill commented 1 year ago

Sheriff Juan 🤠 adds crimes to my rap sheet using new monitoring technologies!

It's almost certainly caused by a mistake I've seen before -- no quotes in the selector for the inserted string.

const isReferenced = parent?.querySelector(`DataSet[name=${name}]`);

should be instead:

const isReferenced = parent?.querySelector(`DataSet[name="${name}"]`);

I'll do a PR for this soon.