Skip to content

Commit 7a57743

Browse files
committed
First basic support for native classes
1 parent 823114e commit 7a57743

5 files changed

Lines changed: 921 additions & 114 deletions

File tree

lib/__tests__/__snapshots__/transform.js.snap

Lines changed: 130 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
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({
77
});
8-
8+
99
~~~~~~~~~~
1010
foo
1111
~~~~~~~~~~
@@ -15,7 +15,7 @@ foo
1515
export default Component.extend({
1616
tagName: \\"\\"
1717
});
18-
18+
1919
~~~~~~~~~~
2020
<div ...attributes>
2121
foo
@@ -29,7 +29,7 @@ exports[`handles \`ariaRole\` correctly 1`] = `
2929
export default Component.extend({
3030
ariaRole: 'button',
3131
});
32-
32+
3333
~~~~~~~~~~
3434
foo
3535
~~~~~~~~~~
@@ -39,7 +39,7 @@ foo
3939
export default Component.extend({
4040
tagName: \\"\\",
4141
});
42-
42+
4343
~~~~~~~~~~
4444
<div role=\\"button\\" ...attributes>
4545
foo
@@ -53,7 +53,7 @@ exports[`handles \`attributeBindings\` correctly 1`] = `
5353
export default Component.extend({
5454
attributeBindings: ['foo', 'bar:baz'],
5555
});
56-
56+
5757
~~~~~~~~~~
5858
foo
5959
~~~~~~~~~~
@@ -63,21 +63,21 @@ foo
6363
export default Component.extend({
6464
tagName: \\"\\",
6565
});
66-
66+
6767
~~~~~~~~~~
6868
<div foo={{this.foo}} baz={{this.bar}} ...attributes>
6969
foo
7070
</div>
7171
=========="
7272
`;
7373
74-
exports[`handles \`classNameBindings\` correctly 1`] = `
74+
exports[`classic components handles \`classNameBindings\` correctly 1`] = `
7575
"==========
7676
7777
export default Component.extend({
7878
classNameBindings: ['a:b', 'x:y:z', 'foo::bar'],
7979
});
80-
80+
8181
~~~~~~~~~~
8282
foo
8383
~~~~~~~~~~
@@ -87,21 +87,21 @@ foo
8787
export default Component.extend({
8888
tagName: \\"\\",
8989
});
90-
90+
9191
~~~~~~~~~~
9292
<div class=\\"{{if this.a \\"b\\"}} {{if this.x \\"y\\" \\"z\\"}} {{unless this.foo \\"bar\\"}}\\" ...attributes>
9393
foo
9494
</div>
9595
=========="
9696
`;
9797
98-
exports[`handles \`classNames\` correctly 1`] = `
98+
exports[`classic components handles \`classNames\` correctly 1`] = `
9999
"==========
100100
101101
export default Component.extend({
102102
classNames: ['foo', 'bar:baz'],
103103
});
104-
104+
105105
~~~~~~~~~~
106106
foo
107107
~~~~~~~~~~
@@ -111,21 +111,21 @@ foo
111111
export default Component.extend({
112112
tagName: \\"\\",
113113
});
114-
114+
115115
~~~~~~~~~~
116116
<div class=\\"foo bar:baz\\" ...attributes>
117117
foo
118118
</div>
119119
=========="
120120
`;
121121
122-
exports[`handles \`elementId\` correctly 1`] = `
122+
exports[`classic components handles \`elementId\` correctly 1`] = `
123123
"==========
124124
125125
export default Component.extend({
126126
elementId: 'qux',
127127
});
128-
128+
129129
~~~~~~~~~~
130130
foo
131131
~~~~~~~~~~
@@ -135,21 +135,21 @@ foo
135135
export default Component.extend({
136136
tagName: \\"\\",
137137
});
138-
138+
139139
~~~~~~~~~~
140140
<div id=\\"qux\\" ...attributes>
141141
foo
142142
</div>
143143
=========="
144144
`;
145145
146-
exports[`handles \`hasComponentCSS\` option correctly 1`] = `
146+
exports[`classic components handles \`hasComponentCSS\` option correctly 1`] = `
147147
"==========
148148
149149
export default Component.extend({
150150
classNames: ['foo', 'bar:baz'],
151151
});
152-
152+
153153
~~~~~~~~~~
154154
foo
155155
~~~~~~~~~~
@@ -159,21 +159,21 @@ foo
159159
export default Component.extend({
160160
tagName: \\"\\",
161161
});
162-
162+
163163
~~~~~~~~~~
164164
<div class=\\"{{styleNamespace}} foo bar:baz\\" ...attributes>
165165
foo
166166
</div>
167167
=========="
168168
`;
169169
170-
exports[`handles single \`classNames\` item correctly 1`] = `
170+
exports[`classic components handles single \`classNames\` item correctly 1`] = `
171171
"==========
172172
173173
export default Component.extend({
174174
classNames: ['foo'],
175175
});
176-
176+
177177
~~~~~~~~~~
178178
foo
179179
~~~~~~~~~~
@@ -183,15 +183,15 @@ foo
183183
export default Component.extend({
184184
tagName: \\"\\",
185185
});
186-
186+
187187
~~~~~~~~~~
188188
<div class=\\"foo\\" ...attributes>
189189
foo
190190
</div>
191191
=========="
192192
`;
193193
194-
exports[`multi-line template 1`] = `
194+
exports[`classic components multi-line template 1`] = `
195195
"==========
196196
export default Component.extend({});
197197
~~~~~~~~~~
@@ -217,13 +217,13 @@ export default Component.extend({
217217
=========="
218218
`;
219219
220-
exports[`replaces existing \`tagName\` 1`] = `
220+
exports[`classic components replaces existing \`tagName\` 1`] = `
221221
"==========
222222
223223
export default Component.extend({
224224
tagName: 'span',
225225
});
226-
226+
227227
~~~~~~~~~~
228228
foo
229229
~~~~~~~~~~
@@ -233,7 +233,111 @@ foo
233233
export default Component.extend({
234234
tagName: \\"\\",
235235
});
236-
236+
237+
~~~~~~~~~~
238+
<span ...attributes>
239+
foo
240+
</span>
241+
=========="
242+
`;
243+
244+
exports[`native components basic 1`] = `
245+
"==========
246+
247+
export default class FooComponent extends Component {
248+
}
249+
250+
~~~~~~~~~~
251+
foo
252+
~~~~~~~~~~
253+
=> tagName: div
254+
~~~~~~~~~~
255+
256+
import { tagName } from \\"@ember-decorators/component\\";
257+
@tagName(\\"\\")
258+
export default class FooComponent extends Component {
259+
}
260+
261+
~~~~~~~~~~
262+
<div ...attributes>
263+
foo
264+
</div>
265+
=========="
266+
`;
267+
268+
exports[`native components handles \`@attributeBindings\` correctly 1`] = `
269+
"==========
270+
271+
import { attributeBindings } from '@ember-decorators/component';
272+
273+
@attributeBindings('foo', 'bar:baz')
274+
export default class FooComponent extends Component {
275+
}
276+
277+
~~~~~~~~~~
278+
foo
279+
~~~~~~~~~~
280+
=> tagName: div
281+
~~~~~~~~~~
282+
283+
import { tagName } from '@ember-decorators/component';
284+
285+
@tagName(\\"\\")
286+
export default class FooComponent extends Component {
287+
}
288+
289+
~~~~~~~~~~
290+
<div foo={{this.foo}} baz={{this.bar}} ...attributes>
291+
foo
292+
</div>
293+
=========="
294+
`;
295+
296+
exports[`native components handles \`elementId\` correctly 1`] = `
297+
"==========
298+
299+
export default class FooComponent extends Component {
300+
elementId = 'qux';
301+
}
302+
303+
~~~~~~~~~~
304+
foo
305+
~~~~~~~~~~
306+
=> tagName: div
307+
~~~~~~~~~~
308+
309+
import { tagName } from \\"@ember-decorators/component\\";
310+
@tagName(\\"\\")
311+
export default class FooComponent extends Component {}
312+
313+
~~~~~~~~~~
314+
<div id=\\"qux\\" ...attributes>
315+
foo
316+
</div>
317+
=========="
318+
`;
319+
320+
exports[`native components replaces existing \`tagName\` 1`] = `
321+
"==========
322+
323+
import { tagName } from '@ember-decorators/component';
324+
325+
@tagName('span')
326+
export default class FooComponent extends Component {
327+
}
328+
329+
~~~~~~~~~~
330+
foo
331+
~~~~~~~~~~
332+
=> tagName: span
333+
~~~~~~~~~~
334+
335+
import { tagName } from '@ember-decorators/component';
336+
337+
@tagName(\\"\\")
338+
export default class FooComponent extends Component {
339+
}
340+
237341
~~~~~~~~~~
238342
<span ...attributes>
239343
foo

0 commit comments

Comments
 (0)