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

validate if in-element has already been transformed #1159

Closed
wants to merge 4 commits into from

Conversation

patricklx
Copy link
Contributor

I was using it for some preprocessing, and then it broke at the end when glimmer was parsing the final template (only if it had in-element)

I was using it for some preprocessing, and then it broke at the end when glimmer was parsing the final template (only if it had in-element)
@lifeart
Copy link
Contributor

lifeart commented Sep 15, 2020

@patricklx
image

@lifeart
Copy link
Contributor

lifeart commented Sep 16, 2020

@patricklx thank you for changes! Could you fix fomatting using --fix flag for eslint?

Comment on lines +455 to +456
value.type === 'StringLiteral' &&
!value.value.startsWith('%cursor:')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, why would we expect guid to be passed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this happens when I do glimmer preprocess -> print (at this stage its passing guid) -> preprocess printed result again fails.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this only happens when compiling not when parsing / printing. Maybe you are using an older version of glimmer-vm that did this during syntax parsing?

Can you describe the tooling that you are using (and the versions) that hit the issue?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created #1164 which shows that we can do the following:

import { preprocess, print } from '@glimmer/syntax';

let template = '{{#in-element this.someElement}}Content here{{/in-element}}';
let ast = preprocess(template);
let reprintedOutput = print(ast);

assert.equal(reprintedOutput, template);

Copy link
Contributor Author

@patricklx patricklx Sep 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, that could be. was trying out custom hbs preprocessing (not ast plugin).
So, i was using the glimmer package directly (v0.42.2).
But when the template was processed by ember it failed to process it.
"ember-source": "^3.21.1"

actually with embroider:
"@embroider/core": "^0.23.0"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this happens when I do glimmer preprocess -> print (at this stage its passing guid) -> preprocess printed result again fails.

Maybe you are using an older version of glimmer-vm that did this during syntax parsing?

Specifically, I think you are probably using a version of glimmer-vm prior to this PR: #1086. That landed in @glimmer/syntax@0.52.1.

Copy link
Contributor Author

@patricklx patricklx Sep 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just tested again to be sure, but this does still fail:

const glimmer = require('@glimmer/syntax');

const result = glimmer.preprocess(`<div>{{#in-element destinationElement~}}
    {{yield yieldHash}}
  {{~/in-element}}</div>`);

const printed = glimmer.print(result);
console.log(printed);

glimmer.preprocess(printed);

console.log:
<div>{{#in-element destinationElement guid="%cursor:0%" insertBefore=undefined~}}{{yield yieldHash}}{{~/in-element}}</div>

error:
SyntaxError: Cannot pass guid from user space

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, updated to latest version works!

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

Successfully merging this pull request may close these issues.

3 participants