question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

data-test selectors are not stripped from colocated component templates

See original GitHub issue

I noticed that not all data-test-* selectors are being stripped from my production build. It seems that the commonality among those that remain is that the selectors that remain are all from component templates that are using the new colocated component file structure (i.e. having the component.hbs file inside the app/component directory alongside the corresponding component.js file.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:20 (14 by maintainers)

github_iconTop GitHub Comments

7reactions
rwjbluecommented, May 6, 2020

ZOMG, I spent a while debugging this 😭, and have a fix. Basically, what is happen (in order) is:

  1. ember-cli-htmlbars’s included hook runs, and does: 1a. gather all AST plugins registered as htmlbars-ast-plugin in the registry 1b. add babel-plugin-htmlbars-inline-precompile to the babel configuration
  2. ember-test-selectors’s included hook runs, and registers a new htmlbars-ast-plugin

Specifically, the babel config is already locked down before ember-test-selectors. I do not think this issue is related to colocation at all (I doubt this ever ran against inline compiled templates), but the fact that colocation happens to desugar into using inline templates (e.g. hbs) makes it much more common to care.

The simplest fix, is to ensure that ember-test-selectors runs before ember-cli-htmlbars, and I’ve confirmed that works when manually tweaked into void-mAlex/test-selector-repro. See https://github.com/simplabs/ember-test-selectors/pull/521.

1reaction
Turbo87commented, May 6, 2020

not from my side. I think it’s a bug in the build pipeline somewhere, but not related to the implementation here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

data-test selectors are not stripped from colocated component ...
It seems that the commonality among those that remain is that the selectors that remain are all from component templates that are using...
Read more >
ember-test-selectors | Yarn - Package Manager
Removes attributes starting with data-test- from HTML tags and component/helper invocations in your templates for production builds.
Read more >
ember-test-selectors - UNPKG
The CDN for ember-test-selectors. ... Other than that, no further breaking ... stripping works for inline template compilation and co-located components ...
Read more >
New features for ember-test-selectors | Mainmatter - Simplabs
Tobias Bieniek announces new features in ember-test-selectors such as automatic binding of data-test-* properties and how these are stripped ...
Read more >
v2 Addon Format (Embroider Compatibility) - Ember RFCs
Own Javascript: Co-located Component Templates. Modules in Own Javascript get no automatic component template co-location.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found