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

interference with existing globally scoped Element and workaround #145

Open
micahscopes opened this issue Apr 8, 2022 · 2 comments
Open

Comments

@micahscopes
Copy link

I'm using vite to run some examples. Somehow the Element object is getting assigned to _Element in functions generated from the inline evaluator, so that the code in the generated functions references the existing window.Element used to make DOM elements.

I found a workaround that's working fine for me, which is to put const Element = this at the very beginning of the inline block.

@kungfooman
Copy link
Sponsor Contributor

It would be nice to rename class Element extends generator in Ganja so it doesn't clash with HTML5 Element anymore, but what would be a better name?

@micahscopes
Copy link
Author

micahscopes commented May 23, 2022

@kungfooman I'm nto sure if this covers what you're doing but I was able to work around my issues by just avoiding using this in the inline function body:

const cga = Algebra(4, 1);
const graphElements = cga.inline(() => {
  let p1 = // ... 
  // ...
  return [
    0x00ff0000, p1, "p1", p2, "p2", p3, "p3", p4, "p4", // points
    0xe0008800, p, "p", // plane
    0xe00000ff, s, "s", // sphere
  ];
})();

const graph = cga.graph(graphElements, {
  conformal: true,
  gl: true,
  grid: true,
  alpha: true,
});

graph.setAttribute("id", "graph");
document.body.appendChild(graph);

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