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

Formatter produce invalid component state #122

Open
StarpTech opened this issue Mar 8, 2019 · 1 comment
Open

Formatter produce invalid component state #122

StarpTech opened this issue Mar 8, 2019 · 1 comment

Comments

@StarpTech
Copy link

Formatting this

$ {
  /* This component rely on https://github.com/mashpie/i18n-node */
  const { req, locale } = out.global;
  const { translationKey, translationParams, plural } = input;
  let message = "";

  if (req && typeof req.t === "function") {
    message = req.t(translationKey, translationParams);
  }
}

-- ${message}

results in

$ //* This component rely on https://github.com/mashpie/i18n-node */
const { req, locale } = out.global;
const { translationKey, translationParams, plural } = input;
let message = "";

if (req && typeof req.t === "function") {
  message = req.t(translationKey, translationParams);
}
-- ${message}

and throws

/home/deus/Repositories/test/node_modules/marko/src/compiler/CompileContext.js:559
                        throw new Error(
                        ^

Error: Invalid node returned from node factory for tag "if".
    at CompileContext.createNodeForEl (/home/deus/Repositories/test/node_modules/marko/src/compiler/CompileContext.js:559:31)
    at Normalizer.normalizeElement (/home/deus/Repositories/test/node_modules/marko/src/compiler/Normalizer.js:109:36)
    at Walker.exit [as _exit] (/home/deus/Repositories/test/node_modules/marko/src/compiler/Normalizer.js:72:50)
    at Walker.walk (/home/deus/Repositories/test/node_modules/marko/src/compiler/Walker.js:134:25)
    at nodes.forEach.node (/home/deus/Repositories/test/node_modules/marko/src/compiler/Walker.js:70:36)
    at ArrayContainer.forEach (/home/deus/Repositories/test/node_modules/marko/src/compiler/ast/ArrayContainer.js:18:26)
    at Walker._walkContainer (/home/deus/Repositories/test/node_modules/marko/src/compiler/Walker.js:69:15)
    at Walker.walk (/home/deus/Repositories/test/node_modules/marko/src/compiler/Walker.js:118:18)
    at TemplateRoot.walk (/home/deus/Repositories/test/node_modules/marko/src/compiler/ast/TemplateRoot.js:167:28)
    at Walker.walk (/home/deus/Repositories/test/node_modules/marko/src/compiler/Walker.js:123:22)
App stopped unexpectedly
@StarpTech
Copy link
Author

This must be related to marko-js/htmljs-parser#68

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

1 participant