Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retain [some?] non-style attributes #15

Open
vwong opened this issue May 17, 2022 · 2 comments
Open

Retain [some?] non-style attributes #15

vwong opened this issue May 17, 2022 · 2 comments

Comments

@vwong
Copy link

vwong commented May 17, 2022

Description

Would it be possible to retain some non-style attributes like <img src=x>, <img alt=x>, and <div aria-labelledby> etc in the snapshot?

Why

Arguably the test for these things could be done with more specialised tools, like testing-library for example, but having it retained in the snapshot is a quick way to increase coverage, so that we can at least pick up accidental changes without having to explicitly code for it.

Possible Implementation & Open Questions

How long is a piece of string? Where do we draw the limits of what gets retained/discarded?

Is this something you're interested in working on?

Yes, happy to create a PR if I knew where/how to make the change.

@DylanPiercey
Copy link
Member

DylanPiercey commented May 17, 2022

@vwong this tool actually does preserve a list of attributes deemed to be visual (https://github.com/eBay/visual-html/blob/master/src/html-properties.ts#L1). I'm not quite sure why img src didn't make the list, I think that should be added.

As far as alt text and aria attributes I feel it belongs in another tool. I've thought since building this that a sister tool for snapshotting and normalizing the a11y tree would be great. Eg it should normalize <label>, aria-label etc. I've wanted to build this "audible-html" for a while but just haven't had the time.

@vwong
Copy link
Author

vwong commented May 17, 2022

audible-html sounds like an even better idea! I might be keen to try building that myself, using this repo as a starting point.

But for now <img src> wasn't preserved in my testing, though the applied styles were.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants