From 1f51087c2527b3f51a85c7608cdbc6deabfc50de Mon Sep 17 00:00:00 2001 From: Joost De Cock Date: Thu, 22 Dec 2022 19:35:14 +0100 Subject: [PATCH] feat(core): Make Part.getId() a prototype method As requested by @BenJamesBen in #3282 --- packages/core/src/part.mjs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/core/src/part.mjs b/packages/core/src/part.mjs index 5943bb4d925..16257650cd4 100644 --- a/packages/core/src/part.mjs +++ b/packages/core/src/part.mjs @@ -78,6 +78,17 @@ Part.prototype.attr = function (name, value, overwrite = false) { return this } +/** + * Gets a free ID to use in the part + * + * @return {string} id - A free ID to use + */ +Part.prototype.getId = function (prefix = '') { + this.freeId += 1 + + return prefix + this.freeId +} + /** * Hide the part *