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

Reuse same object for tagged template quasis. #67

Merged
merged 2 commits into from
Dec 6, 2017

Commits on Dec 5, 2017

  1. Reuse same object for tagged template quasis.

    Spec tagged template literals pass the same object to each invocation of
    the template tag function. This way that object can be used as a cache
    key, for example, using a `Map`, so that parsing of the string contents
    can be cached.
    
    This patch changes the tagged template literal transform to declare a
    frozen top-level array with the quasi strings, and passes that array to
    each invocation. I think it's important to adhere to the spec re:
    freezing, because otherwise people might try to attach properties to the
    object itself as a sort of caching mechanism, which doesn't work in spec
    tagged template literals.
    
    I'm unsure if this is the _best_ way to declare a top-level variable,
    but it seems to work OK :)
    goto-bus-stop committed Dec 5, 2017
    Configuration menu
    Copy the full SHA
    2db8c74 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    6272cc0 View commit details
    Browse the repository at this point in the history