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

builder.element(tagName) throws an error in 6.x #734

Open
runspired opened this issue Jan 20, 2022 · 3 comments
Open

builder.element(tagName) throws an error in 6.x #734

runspired opened this issue Jan 20, 2022 · 3 comments

Comments

@runspired
Copy link

Error:

TypeError: Cannot destructure property 'attrs' of 'options' as it is undefined.
    at Object.buildElement [as element] (/Users/runspired/github/private/fnb/frontend/node_modules/@glimmer/syntax/dist/commonjs/es2017/lib/v1/public-builders.js:158:5)

Example Working in 5.x

Transform:

module.exports = function(env) {
  const b = env.syntax.builders;
  
  return {
    ElementNode(node) {
      return b.element("span");
    }
  }
}

Code to modify:

<Input />
@runspired
Copy link
Author

utilizing npx ember-template-recast@{version} I worked back to this affects all versions of 6.x. I'm not sure why the default for npx ember-template-recast was 5.x until this week (the particular transform this threw for was working fine via this execution only 2 weeks ago).

The global node on my machine is v17.4.0, the project node is v14.17.6

@runspired runspired changed the title builder.element(tagName) throws an error in 6.1.3 builder.element(tagName) throws an error in 6.x Jan 20, 2022
@dcyriller
Copy link
Member

dcyriller commented Jan 20, 2022

I ran into this error while upgrading @glimmer/syntax a while ago here in template-recast:
https://github.com/ember-template-lint/ember-template-recast/pull/627/files#diff-3a4f3cd1ddd47fc9011205425ed890cfab4f79a21f7cbda7ad8055cb0ef82ff2R11

If we want to fix this, we should do it in @glimmer/syntax. As far as I remember it is a very light fix there (a missing ?).

As a work around, you can provide an empty object as a second argument.

@runspired
Copy link
Author

@dcyriller confirm, it came into glimmer/syntax in this PR glimmerjs/glimmer-vm@8e11b91

we'd just need to have options = {} as the default here: https://github.com/glimmerjs/glimmer-vm/blob/a397f489047d89c4b2b6f4bfc4415e780c054b99/packages/%40glimmer/syntax/lib/v1/public-builders.ts#L205

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