Skip to content

Why has AM not taken off? #29

@Jakobud

Description

@Jakobud

I just came across the idea of Attribute Modules today. The advantages seem very clear. I'm curious if anyone knows why AM has not taken off and why it hasn't been adopted more widely by CSS frameworks, etc. It's weird because its from 2014 but I haven't heard about it until I stumbled on it today.

As for feedback, the only way I would change AM is not having multiple values in a single attribute like:

am-Button="wide red uppercase"

While this approach is simple, its definitely more difficult to deal with when you start using JavaScript to interact with these attributes. With classes it's easy because lib's like jQuery have .addClass() and .removeClass(). It's easy to add and remove modifier classes using tools like this. But non such tools exist for custom attributes.

For example, if you are using JavaScript to dynamically change the above button from red to blue, you have to use a bunch of JavaScript to parse through the current values, remove all "color" values and then add then append blue into the attribute value.

A better solution would be for each different type of thing into it's own attribute. So instead of the above, have:

<button am-Button-size="wide" am-Button-color="red" am-Button-text="uppercase">hello</button>

This has all the power of the proposed AM solution, but it uses separation of concerns to compartmentalize each type of attribute. So now, if you need to dynamically change the color of the button, it's just $('button').attr('am-Button-color','blue');. No more parsing out values and having to remove values first, etc. It's just changing a single attribute to a new value and done.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions