Prevent error from unexpected attribute

This commit is contained in:
barsdeveloper
2023-01-04 22:16:51 +01:00
parent 3c5017de91
commit af44de4539
10 changed files with 65 additions and 39 deletions

8
js/entity/EnumEntity.js Executable file
View File

@@ -0,0 +1,8 @@
import ByteEntity from "./ByteEntity"
export default class EnumEntity extends ByteEntity {
constructor(values = 0) {
super(values)
}
}

View File

@@ -25,7 +25,8 @@ import Utility from "../Utility"
/**
* @template {AnyValue} T
* @typedef {(new () => T) | EntityConstructor | StringConstructor | NumberConstructor | BigIntConstructor | BooleanConstructor | ArrayConstructor} AnyValueConstructor
* @typedef {(new () => T) | EntityConstructor | StringConstructor | NumberConstructor | BigIntConstructor
* | BooleanConstructor | ArrayConstructor} AnyValueConstructor
*/
export default class IEntity {
@@ -54,6 +55,12 @@ export default class IEntity {
/** @type {AttributeInformation} */
let attribute = attributes[attributeName]
if (!attribute) {
// Remember attributeName can come from the values and be not defined in the attributes
target[attributeName] = value
continue
}
if (attribute instanceof SubAttributesDeclaration) {
target[attributeName] = {}
defineAllAttributes(