« get me outta code hell

data: CacheableObject, Thing: restore seal(this) behavior - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2025-03-31 10:39:35 -0300
committer(quasar) nebula <qznebula@protonmail.com>2025-04-10 16:02:35 -0300
commit286b4ab5e14adf5c64d1044df4f75bfb6bd329f4 (patch)
tree7fe8fba18ee73488eee67459c53c704156b6cf78 /src/data
parent3c277846ea46282f1fdad91c201940d3685693d4 (diff)
data: CacheableObject, Thing: restore seal(this) behavior
Diffstat (limited to 'src/data')
-rw-r--r--src/data/cacheable-object.js6
-rw-r--r--src/data/thing.js8
2 files changed, 12 insertions, 2 deletions
diff --git a/src/data/cacheable-object.js b/src/data/cacheable-object.js
index 087f7825..a089e325 100644
--- a/src/data/cacheable-object.js
+++ b/src/data/cacheable-object.js
@@ -14,7 +14,7 @@ export default class CacheableObject {
   static cacheValid = Symbol.for('CacheableObject.cacheValid');
   static updateValue = Symbol.for('CacheableObject.updateValues');
 
-  constructor() {
+  constructor({seal = true} = {}) {
     this[CacheableObject.updateValue] = Object.create(null);
     this[CacheableObject.cachedValue] = Object.create(null);
     this[CacheableObject.cacheValid] = Object.create(null);
@@ -34,6 +34,10 @@ export default class CacheableObject {
         this[property] = null;
       }
     }
+
+    if (seal) {
+      Object.seal(this);
+    }
   }
 
   static finalizeCacheableObjectPrototype() {
diff --git a/src/data/thing.js b/src/data/thing.js
index 90453c15..66f73de5 100644
--- a/src/data/thing.js
+++ b/src/data/thing.js
@@ -25,6 +25,10 @@ export default class Thing extends CacheableObject {
   static yamlSourceDocument = Symbol.for('Thing.yamlSourceDocument');
   static yamlSourceDocumentPlacement = Symbol.for('Thing.yamlSourceDocumentPlacement');
 
+  [Symbol.for('Thing.yamlSourceFilename')] = null;
+  [Symbol.for('Thing.yamlSourceDocument')] = null;
+  [Symbol.for('Thing.yamlSourceDocumentPlacement')] = null;
+
   static isThingConstructor = Symbol.for('Thing.isThingConstructor');
   static isThing = Symbol.for('Thing.isThing');
 
@@ -33,11 +37,13 @@ export default class Thing extends CacheableObject {
   static [Symbol.for('Thing.isThingConstructor')] = NaN;
 
   constructor() {
-    super();
+    super({seal: false});
 
     // To detect:
     // Object.hasOwn(object, Symbol.for('Thing.isThing'))
     this[Symbol.for('Thing.isThing')] = NaN;
+
+    Object.seal(this);
   }
 
   static [Symbol.for('Thing.selectAll')] = _wikiData => [];