Seaside
Seaside copied to clipboard
Add a method to add data-test attributes
Several frontend frameworks support data-test-* attributes. They are intended to be used in tests, not in production. It allows tests to easily identify elements in the DOM, without relying on long CSS selectors or element IDs, and without impacting the behaviour of the application. In fact, several frameworks render data-test-* attributes only during development, not during production. It would be nice if Seaside would support data-test-* attributes too.
The first step is to have a dedicated method to add a data-test-* attribute. Seaside provides WATagBrush>>#htmlDataAttributeAt:put:, which means that today code like this is required to add a data-test-* attribute:
html htmlDataAttributeAt: 'test-some-element' put: true
I suggest adding:
WATagBrush >> htmlDataTestAttribute: aString
self attributes at: 'data-test-' , aString put: true
How would you switch them off for production? Different canvas class? #ifTrue: in component code? Configuration attribute?
@marschall I was thinking a separate configuration attribute.