Description
Views.createFromIfcStoreys throws instead of skipping when an IFCBUILDINGSTOREY item has no Name (or no Elevation) attribute at all.
|
if (!("value" in storey.Name && "value" in storey.Elevation)) { |
for (const storey of storeysData) {
if (!("value" in storey.Name && "value" in storey.Elevation)) {
continue;
}
...
When storey.Name (or storey.Elevation) is undefined — which happens for a storey item that has no Name/Elevation attribute in the source IFC — "value" in storey.Name throws:
TypeError: Cannot use 'in' operator to search for 'value' in undefined
instead of just failing the guard and being skipped via continue, as the code clearly intends.
This is reproducible against the currently published 3.4.8 (same code on main as of the commit linked above, package.json still reads 3.4.0).
Reproduction
Load any IFC model containing a BUILDINGSTOREY whose Name (or Elevation) attribute is absent, then call:
await views.createFromIfcStoreys();
This throws a TypeError instead of skipping the malformed storey.
Suggested fix
Short-circuit correctly instead of relying on && to protect the second in check when the first operand can itself be undefined:
for (const storey of storeysData) {
if (!(storey.Name && "value" in storey.Name && storey.Elevation && "value" in storey.Elevation)) {
continue;
}
...
Environment
@thatopen/components 3.4.8 (also present on main)
Description
Views.createFromIfcStoreysthrows instead of skipping when anIFCBUILDINGSTOREYitem has noName(or noElevation) attribute at all.engine_components/packages/core/src/core/Views/index.ts
Line 155 in 1d8ca36
When
storey.Name(orstorey.Elevation) isundefined— which happens for a storey item that has noName/Elevationattribute in the source IFC —"value" in storey.Namethrows:instead of just failing the guard and being skipped via
continue, as the code clearly intends.This is reproducible against the currently published
3.4.8(same code onmainas of the commit linked above, package.json still reads3.4.0).Reproduction
Load any IFC model containing a
BUILDINGSTOREYwhoseName(orElevation) attribute is absent, then call:This throws a
TypeErrorinstead of skipping the malformed storey.Suggested fix
Short-circuit correctly instead of relying on
&&to protect the secondincheck when the first operand can itself beundefined:Environment
@thatopen/components3.4.8 (also present onmain)