]> Lady’s Gitweb - Etiquette/commitdiff
Add methods to get the system of a Tag
authorLady <redacted>
Tue, 20 Jun 2023 01:17:28 +0000 (18:17 -0700)
committerLady <redacted>
Tue, 20 Jun 2023 01:17:28 +0000 (18:17 -0700)
model.js
model.test.js

index cfd228d88f12e7e7625a1f2374f3775d57021683..7e0fefc9e5836bcd5b3080708111dd10894b45b4 100644 (file)
--- a/model.js
+++ b/model.js
@@ -439,6 +439,9 @@ class Tag {
    * ※ This function can be used to check if the provided value has
    * private tag features.
    *
+   * ※ `Tag::system` is an overridable, publicly‐accessible means of
+   * accessing the system.
+   *
    * ※ This function is not exposed.
    */
   static getSystem($) {
@@ -489,6 +492,15 @@ class Tag {
     return this.#kind;
   }
 
+  /**
+   * Returns the `TagSystem` for this `Tag`.
+   *
+   * ※ Internally, `Tag.getSystem` is preferred.
+   */
+  get system() {
+    return this.#system;
+  }
+
   /**
    * Persist this `Tag` to storage and return an ActivityStreams
    * serialization of a Tag Activity representing any changes, or
@@ -859,8 +871,8 @@ const {
           function Tag() {
             throw new TypeError("Tags must belong to a System.");
           };
-        const { prototype: methods } = this;
-        delete methods.constructor;
+        const { prototype: staticFeatures } = this;
+        delete staticFeatures.constructor;
         Object.defineProperty(superclass, "prototype", {
           configurable: false,
           enumerable: false,
@@ -869,7 +881,7 @@ const {
         });
         Object.defineProperties(
           superclass,
-          Object.getOwnPropertyDescriptors(methods),
+          Object.getOwnPropertyDescriptors(staticFeatures),
         );
       }
 
@@ -1001,6 +1013,11 @@ const {
         }
       }
 
+      /** Returns the `TagSystem` for this `Tag` constructor. */
+      get system() {
+        return this.#system;
+      }
+
       /**
        * Returns a new `Tag` constructed from the provided data and
        * with the provided identifier.
index ed1430e8a49246c1a97190eb3e64ca9e443bbad3..4396d37def8892db01a6f32076ca066b31773a21 100644 (file)
@@ -280,6 +280,12 @@ describe("TagSystem", () => {
       });
     });
 
+    describe(".system", () => {
+      it("[[Call]] returns the `TagSystem`", () => {
+        assertEquals(Tag.system, system);
+      });
+    });
+
     // `.[Storage.toInstance]` is tested by `.fromIdentifier`.
 
     describe("::addAltLabel", () => {
@@ -939,6 +945,12 @@ describe("TagSystem", () => {
       });
     });
 
+    describe("::system", () => {
+      it("[[Get]] returns the tag system", () => {
+        assertStrictEquals(new Tag().system, system);
+      });
+    });
+
     // `::tagURI` is tested by a `.fromTagURI`.
 
     describe("::taggingEntity", () => {
This page took 0.05906 seconds and 4 git commands to generate.