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

Static tags #364

Closed
Rich-Harris opened this issue Mar 10, 2017 · 6 comments
Closed

Static tags #364

Rich-Harris opened this issue Mar 10, 2017 · 6 comments

Comments

@Rich-Harris
Copy link
Member

Sometimes you know for a fact that some data isn't going to change. In those situations there's no point adding update logic.

Ractive (and I think Polymer, maybe?) allows component authors to use square brackets to denote that some data is fixed:

<p>{{willChange}}</p>
<p>[[wontChange]]</p>

Gets a bit confusing when blocks are involved — need to have a clear idea about what should happen if you have curlies inside square brackets and vice versa.

@PaulBGD
Copy link
Member

PaulBGD commented Mar 11, 2017

I actually think this would be more useful in passing attributes, because I don't think there's many use cases where the data doesn't change from within a component.

@TehShrike
Copy link
Member

This would be difficult to resolve with a potential syntax change to drop double-curlies for single-curlies. I like the idea in theory - though I feel like I'd rather note it in the exported object instead of the template.

export default {
  data() {
    return {
      willChange: 1,
      wontchange: 2
    }
  }
  static: [ 'wontChange' ]
}

@tivac
Copy link
Contributor

tivac commented Jan 15, 2018

I would love to see this, given my predilection for using modular-css to style things. I like the template syntax idea for its ease-of-use but the component-level marking approach from @TehShrike is probably clearer overall.

@Rich-Harris
Copy link
Member Author

This is yet another issue that is basically a non-issue post-RFC-1:

<script>
  export let willChange = 1;
  const wontChange = 2;
</script>

<p>{willChange}</p>
<p>{wontChange}</p>

The same applies to modular CSS approaches:

<script>
  import styles from './styles.css';
</script>

<div class={styles.foo}>
  ...
</div>

@Rich-Harris
Copy link
Member Author

(To be clear, let wontChange = 2 would also not get the reactivity treatment, unless there was a post-declaration assignment, because it's not exported. Just using const to illustrate the point)

@Conduitry
Copy link
Member

As noted above, this is handled in v3 by keeping track of whether there are any reassignments to a variable. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants