Skip to content

Commit 2281c62

Browse files
committed
First basic support for native classes
1 parent 32a0e6b commit 2281c62

5 files changed

Lines changed: 908 additions & 112 deletions

File tree

lib/__tests__/__snapshots__/transform.js.snap

Lines changed: 113 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`basic 1`] = `
3+
exports[`classic components basic 1`] = `
44
"==========
55
66
export default Component.extend({
@@ -23,7 +23,7 @@ foo
2323
=========="
2424
`;
2525
26-
exports[`handles \`attributeBindings\` correctly 1`] = `
26+
exports[`classic components handles \`attributeBindings\` correctly 1`] = `
2727
"==========
2828
2929
export default Component.extend({
@@ -47,7 +47,7 @@ foo
4747
=========="
4848
`;
4949
50-
exports[`handles \`classNameBindings\` correctly 1`] = `
50+
exports[`classic components handles \`classNameBindings\` correctly 1`] = `
5151
"==========
5252
5353
export default Component.extend({
@@ -71,7 +71,7 @@ foo
7171
=========="
7272
`;
7373
74-
exports[`handles \`classNames\` correctly 1`] = `
74+
exports[`classic components handles \`classNames\` correctly 1`] = `
7575
"==========
7676
7777
export default Component.extend({
@@ -95,7 +95,7 @@ foo
9595
=========="
9696
`;
9797
98-
exports[`handles \`elementId\` correctly 1`] = `
98+
exports[`classic components handles \`elementId\` correctly 1`] = `
9999
"==========
100100
101101
export default Component.extend({
@@ -119,7 +119,7 @@ foo
119119
=========="
120120
`;
121121
122-
exports[`handles \`hasComponentCSS\` option correctly 1`] = `
122+
exports[`classic components handles \`hasComponentCSS\` option correctly 1`] = `
123123
"==========
124124
125125
export default Component.extend({
@@ -143,7 +143,7 @@ foo
143143
=========="
144144
`;
145145
146-
exports[`handles single \`classNames\` item correctly 1`] = `
146+
exports[`classic components handles single \`classNames\` item correctly 1`] = `
147147
"==========
148148
149149
export default Component.extend({
@@ -167,7 +167,7 @@ foo
167167
=========="
168168
`;
169169
170-
exports[`multi-line template 1`] = `
170+
exports[`classic components multi-line template 1`] = `
171171
"==========
172172
export default Component.extend({});
173173
~~~~~~~~~~
@@ -193,7 +193,7 @@ export default Component.extend({
193193
=========="
194194
`;
195195
196-
exports[`replaces existing \`tagName\` 1`] = `
196+
exports[`classic components replaces existing \`tagName\` 1`] = `
197197
"==========
198198
199199
export default Component.extend({
@@ -216,3 +216,107 @@ foo
216216
</span>
217217
=========="
218218
`;
219+
220+
exports[`native components basic 1`] = `
221+
"==========
222+
223+
export default class FooComponent extends Component {
224+
}
225+
226+
~~~~~~~~~~
227+
foo
228+
~~~~~~~~~~
229+
=> tagName: div
230+
~~~~~~~~~~
231+
232+
import { tagName } from \\"@ember-decorators/component\\";
233+
@tagName(\\"\\")
234+
export default class FooComponent extends Component {
235+
}
236+
237+
~~~~~~~~~~
238+
<div ...attributes>
239+
foo
240+
</div>
241+
=========="
242+
`;
243+
244+
exports[`native components handles \`@attributeBindings\` correctly 1`] = `
245+
"==========
246+
247+
import { attributeBindings } from '@ember-decorators/component';
248+
249+
@attributeBindings('foo', 'bar:baz')
250+
export default class FooComponent extends Component {
251+
}
252+
253+
~~~~~~~~~~
254+
foo
255+
~~~~~~~~~~
256+
=> tagName: div
257+
~~~~~~~~~~
258+
259+
import { tagName } from '@ember-decorators/component';
260+
261+
@tagName(\\"\\")
262+
export default class FooComponent extends Component {
263+
}
264+
265+
~~~~~~~~~~
266+
<div foo={{this.foo}} baz={{this.bar}} ...attributes>
267+
foo
268+
</div>
269+
=========="
270+
`;
271+
272+
exports[`native components handles \`elementId\` correctly 1`] = `
273+
"==========
274+
275+
export default class FooComponent extends Component {
276+
elementId = 'qux';
277+
}
278+
279+
~~~~~~~~~~
280+
foo
281+
~~~~~~~~~~
282+
=> tagName: div
283+
~~~~~~~~~~
284+
285+
import { tagName } from \\"@ember-decorators/component\\";
286+
@tagName(\\"\\")
287+
export default class FooComponent extends Component {}
288+
289+
~~~~~~~~~~
290+
<div id=\\"qux\\" ...attributes>
291+
foo
292+
</div>
293+
=========="
294+
`;
295+
296+
exports[`native components replaces existing \`tagName\` 1`] = `
297+
"==========
298+
299+
import { tagName } from '@ember-decorators/component';
300+
301+
@tagName('span')
302+
export default class FooComponent extends Component {
303+
}
304+
305+
~~~~~~~~~~
306+
foo
307+
~~~~~~~~~~
308+
=> tagName: span
309+
~~~~~~~~~~
310+
311+
import { tagName } from '@ember-decorators/component';
312+
313+
@tagName(\\"\\")
314+
export default class FooComponent extends Component {
315+
}
316+
317+
~~~~~~~~~~
318+
<span ...attributes>
319+
foo
320+
</span>
321+
=========="
322+
`;

0 commit comments

Comments
 (0)