Skip to content

Commit 3c405af

Browse files
authored
Merge pull request #863 from sveltejs/short-method-names
use short method names
2 parents 3f8a59c + d27e473 commit 3c405af

File tree

49 files changed

+774
-773
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+774
-773
lines changed

src/generators/dom/Block.ts

+22-21
Original file line numberDiff line numberDiff line change
@@ -226,53 +226,53 @@ export default class Block {
226226
}
227227

228228
if (this.builders.create.isEmpty()) {
229-
properties.addBlock(`create: @noop,`);
229+
properties.addBlock(`c: @noop,`);
230230
} else {
231231
properties.addBlock(deindent`
232-
create: function() {
232+
c: function create() {
233233
${this.builders.create}
234-
${!this.builders.hydrate.isEmpty() && `this.hydrate();`}
234+
${!this.builders.hydrate.isEmpty() && `this.h();`}
235235
},
236236
`);
237237
}
238238

239239
if (this.generator.hydratable) {
240240
if (this.builders.claim.isEmpty()) {
241-
properties.addBlock(`claim: @noop,`);
241+
properties.addBlock(`l: @noop,`);
242242
} else {
243243
properties.addBlock(deindent`
244-
claim: function(nodes) {
244+
l: function claim(nodes) {
245245
${this.builders.claim}
246-
${!this.builders.hydrate.isEmpty() && `this.hydrate();`}
246+
${!this.builders.hydrate.isEmpty() && `this.h();`}
247247
},
248248
`);
249249
}
250250
}
251251

252252
if (!this.builders.hydrate.isEmpty()) {
253253
properties.addBlock(deindent`
254-
hydrate: function() {
254+
h: function hydrate() {
255255
${this.builders.hydrate}
256256
},
257257
`);
258258
}
259259

260260
if (this.builders.mount.isEmpty()) {
261-
properties.addBlock(`mount: @noop,`);
261+
properties.addBlock(`m: @noop,`);
262262
} else {
263263
properties.addBlock(deindent`
264-
mount: function(#target, anchor) {
264+
m: function mount(#target, anchor) {
265265
${this.builders.mount}
266266
},
267267
`);
268268
}
269269

270270
if (this.hasUpdateMethod) {
271271
if (this.builders.update.isEmpty()) {
272-
properties.addBlock(`update: @noop,`);
272+
properties.addBlock(`p: @noop,`);
273273
} else {
274274
properties.addBlock(deindent`
275-
update: function(changed, ${this.params.join(', ')}) {
275+
p: function update(changed, ${this.params.join(', ')}) {
276276
${this.builders.update}
277277
},
278278
`);
@@ -282,20 +282,20 @@ export default class Block {
282282
if (this.hasIntroMethod) {
283283
if (hasIntros) {
284284
properties.addBlock(deindent`
285-
intro: function(#target, anchor) {
285+
i: function intro(#target, anchor) {
286286
if (${introing}) return;
287287
${introing} = true;
288288
${hasOutros && `${outroing} = false;`}
289289
290290
${this.builders.intro}
291291
292-
this.mount(#target, anchor);
292+
this.m(#target, anchor);
293293
},
294294
`);
295295
} else {
296296
properties.addBlock(deindent`
297-
intro: function(#target, anchor) {
298-
this.mount(#target, anchor);
297+
i: function intro(#target, anchor) {
298+
this.m(#target, anchor);
299299
},
300300
`);
301301
}
@@ -304,7 +304,7 @@ export default class Block {
304304
if (this.hasOutroMethod) {
305305
if (hasOutros) {
306306
properties.addBlock(deindent`
307-
outro: function(${this.alias('outrocallback')}) {
307+
o: function outro(${this.alias('outrocallback')}) {
308308
if (${outroing}) return;
309309
${outroing} = true;
310310
${hasIntros && `${introing} = false;`}
@@ -315,29 +315,30 @@ export default class Block {
315315
},
316316
`);
317317
} else {
318+
// TODO should this be a helper?
318319
properties.addBlock(deindent`
319-
outro: function(outrocallback) {
320+
o: function outro(outrocallback) {
320321
outrocallback();
321322
},
322323
`);
323324
}
324325
}
325326

326327
if (this.builders.unmount.isEmpty()) {
327-
properties.addBlock(`unmount: @noop,`);
328+
properties.addBlock(`u: @noop,`);
328329
} else {
329330
properties.addBlock(deindent`
330-
unmount: function() {
331+
u: function unmount() {
331332
${this.builders.unmount}
332333
},
333334
`);
334335
}
335336

336337
if (this.builders.destroy.isEmpty()) {
337-
properties.addBlock(`destroy: @noop`);
338+
properties.addBlock(`d: @noop`);
338339
} else {
339340
properties.addBlock(deindent`
340-
destroy: function() {
341+
d: function destroy() {
341342
${this.builders.destroy}
342343
}
343344
`);

src/generators/dom/index.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -236,23 +236,23 @@ export default function dom(
236236
this._fragment = @create_main_fragment(this._state, this);
237237
238238
${generator.customElement ? deindent`
239-
this._fragment.create();
240-
this._fragment.${block.hasIntroMethod ? 'intro' : 'mount'}(this.shadowRoot, null);
239+
this._fragment.c();
240+
this._fragment.${block.hasIntroMethod ? 'i' : 'm'}(this.shadowRoot, null);
241241
242242
if (options.target) this._mount(options.target, options.anchor || null);
243243
` : deindent`
244244
if (options.target) {
245245
${generator.hydratable
246246
? deindent`
247247
var nodes = @children(options.target);
248-
options.hydrate ? this._fragment.claim(nodes) : this._fragment.create();
248+
options.hydrate ? this._fragment.l(nodes) : this._fragment.c();
249249
nodes.forEach(@detachNode);
250250
` :
251251
deindent`
252252
${options.dev && `if (options.hydrate) throw new Error("options.hydrate only works if the component was compiled with the \`hydratable: true\` option");`}
253-
this._fragment.create();
253+
this._fragment.c();
254254
`}
255-
this._fragment.${block.hasIntroMethod ? 'intro' : 'mount'}(options.target, options.anchor || null);
255+
this._fragment.${block.hasIntroMethod ? 'i' : 'm'}(options.target, options.anchor || null);
256256
257257
${(generator.hasComponents || generator.hasComplexBindings || templateProperties.oncreate || generator.hasIntroTransitions) && deindent`
258258
${generator.hasComponents && `this._lock = true;`}

src/generators/dom/visitors/Component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,10 @@ export default function visitComponent(
230230
${beforecreate}
231231
`);
232232

233-
block.builders.create.addLine(`${name}._fragment.create();`);
233+
block.builders.create.addLine(`${name}._fragment.c();`);
234234

235235
block.builders.claim.addLine(
236-
`${name}._fragment.claim( ${state.parentNodes} );`
236+
`${name}._fragment.l( ${state.parentNodes} );`
237237
);
238238

239239
block.builders.mount.addLine(

0 commit comments

Comments
 (0)