From cdc1a89184d066fb57fb9df4890f6e74b439caf0 Mon Sep 17 00:00:00 2001 From: Vincent Fretin Date: Tue, 26 Nov 2024 14:12:20 +0100 Subject: [PATCH] Use component.attrName that includes the name plus optional id like event-set__click when checking for implicit value (from mixin or primitive) --- src/lib/entity.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/lib/entity.js b/src/lib/entity.js index 01439fb7..338cb59e 100644 --- a/src/lib/entity.js +++ b/src/lib/entity.js @@ -289,8 +289,8 @@ function getImplicitValue(component, source) { isInherited = defaults && /* eslint-disable-next-line no-prototype-builtins */ - defaults.hasOwnProperty(component.name) && - Object.keys(defaults[component.name]).length === 0; + defaults.hasOwnProperty(component.attrName) && + Object.keys(defaults[component.attrName]).length === 0; Object.keys(component.schema).forEach(function (propertyName) { var propertyValue = getFromAttribute(component, propertyName, source); if (propertyValue === undefined) { @@ -373,11 +373,11 @@ function getMixedValue(component, propertyName, source) { for (var i = 0; value === undefined && i < reversedMixins.length; i++) { var mixin = reversedMixins[i]; /* eslint-disable-next-line no-prototype-builtins */ - if (mixin.attributes.hasOwnProperty(component.name)) { + if (mixin.attributes.hasOwnProperty(component.attrName)) { if (!propertyName) { - value = mixin.getAttribute(component.name); + value = mixin.getAttribute(component.attrName); } else { - value = mixin.getAttribute(component.name)[propertyName]; + value = mixin.getAttribute(component.attrName)[propertyName]; } } } @@ -399,11 +399,14 @@ function getInjectedValue(component, propertyName, source) { var value; var primitiveDefaults = source.defaultComponentsFromPrimitive; /* eslint-disable-next-line no-prototype-builtins */ - if (primitiveDefaults && primitiveDefaults.hasOwnProperty(component.name)) { + if ( + primitiveDefaults && + primitiveDefaults.hasOwnProperty(component.attrName) + ) { if (!propertyName) { - value = primitiveDefaults[component.name]; + value = primitiveDefaults[component.attrName]; } else { - value = primitiveDefaults[component.name][propertyName]; + value = primitiveDefaults[component.attrName][propertyName]; } } return value;