adobe / aem-core-wcm-components

Standardized components to build websites with AEM.
https://docs.adobe.com/content/help/en/experience-manager-core-components/using/introduction.html
Apache License 2.0
723 stars 737 forks source link

The Component model is unnecessarily initialized #2776

Open paulochang opened 3 weeks ago

paulochang commented 3 weeks ago

Bug Report

Current Behavior Some components retrieve the component id from its corresponding sling model (i.e The accordion component) while others explicitly initialize an instance of the Component model (i.e. The button component). This last initialization is unnecessary (as all component's sling models inherit and implement the main Component model).

Expected behavior/code All components should retrieve the Component's ID directly from its corresponding sling model, no further initialization is needed.

Environment

Possible Solution I would like to have all the initialization and calls to the general component model replaced with a call to the specific component model for each model.

Additional context / Screenshots

Example:

Given the existing Button HTL code

<button data-sly-use.button="com.adobe.cq.wcm.core.components.models.Button"
        data-sly-use.component="com.adobe.cq.wcm.core.components.models.Component"
        ....
        id="${component.id}"

We'd do a replacement with the following code instead

<button data-sly-use.button="com.adobe.cq.wcm.core.components.models.Button"
        ...
        id="${button.id}"