@el7ven/cookie-kit 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@el7ven/cookie-kit",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "type": "module",
5
5
  "main": "./src/index.js",
6
6
  "module": "./src/index.js",
package/src/core/index.js CHANGED
@@ -226,7 +226,8 @@ export class CookieKitCore {
226
226
  Object.keys(this.config.categories).forEach(id => {
227
227
  const category = this.config.categories[id]
228
228
  if (category?.enabled === true) {
229
- next[id] = !!category.required
229
+ // For enabled categories, set to required status OR false if not required
230
+ next[id] = category.required === true
230
231
  }
231
232
  })
232
233
  return next
@@ -239,7 +240,7 @@ export class CookieKitCore {
239
240
  const normalized = this.getDefaultCategoriesState()
240
241
  Object.keys(categories || {}).forEach(id => {
241
242
  if (Object.prototype.hasOwnProperty.call(normalized, id)) {
242
- normalized[id] = !!categories[id] || !!this.config.categories[id]?.required
243
+ normalized[id] = !!categories[id] || this.config.categories[id]?.required === true
243
244
  }
244
245
  })
245
246
 
@@ -294,7 +295,7 @@ export class CookieKitCore {
294
295
  Object.keys(this.config.categories).forEach(id => {
295
296
  const category = this.config.categories[id]
296
297
  if (category?.enabled === true) {
297
- categories[id] = selectedSet.has(id) || !!category.required
298
+ categories[id] = selectedSet.has(id) || category.required === true
298
299
  }
299
300
  })
300
301
  return this.saveConsent(categories, source)