0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-12-01 09:21:21 +01:00
Commit Graph

99 Commits

Author SHA1 Message Date
Rich Harris
286cabaf63 oops 2018-04-15 21:09:49 -04:00
Rich Harris
21168bf5f1 remove v1 parser tests 2018-04-15 20:18:15 -04:00
Rich Harris
35f4a1f063 add codes to errors 2018-04-15 10:31:23 -04:00
Rich Harris
7576d7dc93 update keyed each block syntax 2018-04-14 14:05:01 -04:00
Rich Harris
9bba8d18d1 implement dynamic components etc 2018-04-14 14:01:28 -04:00
Rich Harris
cb514afde4 more tests, support svelte: elements 2018-04-13 11:01:25 -04:00
Rich Harris
258466ebbe attribute shorthand 2018-04-12 23:11:28 -04:00
Rich-Harris
90a372ebf3 brute force new keyed each block syntax 2018-04-10 22:49:21 -04:00
Rich-Harris
cc0055cf82 update parser for v2 2018-04-10 21:48:03 -04:00
Rich-Harris
eebd47d02b add v2 parser tests, handle single curly tags 2018-04-08 11:25:02 -07:00
Rich-Harris
416fc0c81b include spread with other attributes 2018-03-27 20:07:03 -04:00
Rich-Harris
d0c696bb2b merge master -> mrkishi-spreadh 2018-03-27 20:06:34 -04:00
Jacob Wright
04f5d5c975 Adds actions to components
Actions add additional functionality to elements within your component's template that may be difficult to add with other mechanisms. Examples of functionality which actions makes trivial to attach are:
* tooltips
* image lazy loaders
* drag and drop functionality

Actions can be added to an element with the `use` directive.

```html
<img use:lazyload data-src="giant-photo.jpg>
```

Data may be passed to the action as an object literal (e.g. `use:b="{ setting: true }"`, a literal value (e.g. `use:b="'a string'"`), or a value or function from your component's state (e.g. `add:b="foo"` or `add:b="foo()"`).

Actions are defined in a "actions" property on your component definition.

```html
<script>
  export default {
    actions: {
      b(node, data) {
        // do something
        return {
          update(data) {},
          destroy() {}
        }
      }
    }
  }
</script>
```

A action is a function which receives a reference to an element and optionally the data if it is added in the HTML. This function can then attach listeners or alter the element as needed. The action can optionally return an object with the methods `update(data)` and `destroy()`.

When data is added in the HTML and comes from state, the action's `update(data)` will be called if defined whenever the state is changed.

When the element is removed from the DOM `destroy()` will be called if provided, allowing for cleanup of event listeners, etc.

See https://github.com/sveltejs/svelte/issues/469 for discussion around this feature and more examples of how it could be used.
2018-03-19 15:23:27 -06:00
mrkishi
b5102f4f1b Add spread -- rough idea 2018-03-16 16:04:28 -03:00
Rich Harris
39694c31c3 nicer error messages 2018-03-15 17:03:44 -04:00
Rich Harris
f97036dd39 error if ref:foo has a value 2018-03-15 14:49:37 -04:00
Jacob Wright
6d4f8d889a Refactor directive parsing for code reuse
This removes the copy-pasta for directive parsing and removes the need for special if-else cases for each directive.
2018-03-15 11:14:29 -06:00
Rich Harris
ff67b137c4 empty blocks are a dev warning, not an error 2018-02-10 11:46:23 -05:00
Rich Harris
a4d08c205a error on unclosed comments and blocks with only whitespace 2018-02-07 09:11:28 -05:00
Christopher Pfohl
b55ccc6d9f Make sure scripts are passing good data so it's only the parse that can go wrong 2018-02-07 06:53:32 -05:00
Christopher Pfohl
c62f77a5d2 Empty Each Blocks should have consistent behavior.
Here the `error-each-blocks-empty` behaves as expected. It throws a ParseError.
I can't get the whitespace errors to repro in the tests. They're easily seen
here: https://svelte.technology/repl?version=1.51.0&gist=e1596f9631619a689e85c80e46506692

If you uncomment each section in sequence it demonstrates the behavior. I can't
quite figure out why my examples don't work.
2018-02-07 06:28:24 -05:00
Rich Harris
80c55b1e51 oops 2018-01-18 10:35:25 -05:00
Rich Harris
a85b09ea97 handle wacky identifier names in templates 2018-01-18 09:25:50 -05:00
Rich Harris
20962f9d82 add option to disable two-way binding (#54) 2017-12-30 10:38:10 -05:00
Efthymis Sarmpanis
e3b5f5250e Failing test for improper toString override in CompileError 2017-12-13 00:00:22 +01:00
Rich Harris
5904a647db
support dynamic import - closes #1003 2017-12-10 20:09:09 -05:00
Rich Harris
0d42ff84db fix tests, finish renaming stuff 2017-12-04 21:32:22 -05:00
Rich Harris
4f991536d4 parse :Switch tags 2017-12-03 14:30:25 -05:00
Rich Harris
d783993d23 halfway there 2017-11-25 00:01:00 -05:00
Rich Harris
908fe2ab7a parse await-then-catch 2017-11-24 19:02:18 -05:00
Jacob Mischka
5d27d3fda7
Add array destructuring for each contexts
Fixes #888
2017-10-09 20:38:26 -05:00
Rich Harris
7a8c8fd577 replace {{yield}} with <slot/> 2017-08-26 15:50:19 -04:00
Rich Harris
82559c3775 support ref:foo as a CSS selector (#693) 2017-07-30 14:28:08 -04:00
Rich Harris
c98e1f49d3 update parser tests 2017-06-25 17:15:52 -04:00
Rich Harris
c4ad36023c move whitespace logic out of parse and into preprocess 2017-06-25 16:32:24 -04:00
Rich Harris
135f626395 include ast in svelte.compile return value (#632) 2017-06-12 21:49:38 -04:00
Rich Harris
10ecd81734 prettierfy test files 2017-06-02 22:04:36 -04:00
Rich Harris
d752959ef1 change error message for invalid bindings 2017-05-28 16:12:37 -04:00
Rich Harris
5ccc200222 separate parsing rules for textareas 2017-05-27 12:29:01 -04:00
Rich-Harris
53c5c32da3 allow parameter-less transitions 2017-04-26 14:33:44 -04:00
Rich-Harris
2784ae0ade parse transition directives 2017-04-25 16:09:41 -04:00
Rich-Harris
75e8d6205e better error for bind:value="{{foo}}" - fixes #437 2017-04-02 17:54:04 -04:00
Rich-Harris
05ea031895 prevent unclosed <script> causing infinite loop 2017-04-02 13:46:06 -04:00
Rich-Harris
fc646925db make it easier to run parser tests solo 2017-04-02 13:45:01 -04:00
Rich-Harris
4360a03ffd parse <:Window> tags 2017-03-17 21:55:30 -04:00
Rich Harris
efce7acabe Merge pull request #385 from sveltejs/gh-383
allow reserved words in tags e.g. {{class}}
2017-03-17 20:22:13 -04:00
Rich Harris
854a37c0d7 allow reserved words in tags e.g. {{class}} (#383) 2017-03-17 15:49:21 -04:00
Rich Harris
e6d088d753 implement :shorthand attributes 2017-03-17 15:31:54 -04:00
Rich Harris
5866a99b9a treat binding values as expressions 2017-03-16 17:53:55 -04:00
Rich-Harris
60ed068a59 move tests around to facilitate registering babel based on environment 2017-03-07 14:10:28 -05:00