Skip to content

Commit c142214

Browse files
committed
feat(core basepattern): Assign each pattern a UUID.
1 parent 8b70876 commit c142214

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/core/basepattern.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99
import events from "./events";
1010
import logging from "./logging";
11+
import create_uuid from "./uuid";
1112

1213
const log = logging.getLogger("basepattern");
1314

@@ -35,6 +36,7 @@ class BasePattern {
3536
el = el[0];
3637
}
3738
this.el = el;
39+
this.uuid = create_uuid();
3840

3941
// Notify pre-init
4042
this.el.dispatchEvent(

src/core/basepattern.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ describe("Basepattern class tests", function () {
3535
expect(pat.name).toBe("example");
3636
expect(pat.trigger).toBe(".example");
3737
expect(typeof pat.parser.parse).toBe("function");
38+
39+
// Test more attributes
40+
expect(pat.el).toBe(el);
41+
expect(pat.uuid).toMatch(/^[0-9a-f\-]*$/);
3842
});
3943

4044
it("1.2 - Options are created with grouping per default.", async function () {

0 commit comments

Comments
 (0)