Skip to content

Commit ac4ff53

Browse files
committedApr 30, 2018
Merge branch 'master' into gh-984
2 parents 4a67542 + d010aff commit ac4ff53

File tree

57 files changed

+310
-430
lines changed

Some content is hidden

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

57 files changed

+310
-430
lines changed
 

‎src/compile/dom/Block.ts

+20-12
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ export default class Block {
140140
}
141141

142142
toString() {
143+
const { dev } = this.compiler.options;
144+
143145
let introing;
144146
const hasIntros = !this.builders.intro.isEmpty();
145147
if (hasIntros) {
@@ -177,10 +179,16 @@ export default class Block {
177179
if (this.builders.create.isEmpty() && this.builders.hydrate.isEmpty()) {
178180
properties.addBlock(`c: @noop,`);
179181
} else {
182+
const hydrate = !this.builders.hydrate.isEmpty() && (
183+
this.compiler.options.hydratable
184+
? `this.h()`
185+
: this.builders.hydrate
186+
);
187+
180188
properties.addBlock(deindent`
181-
c: function create() {
189+
${dev ? 'c: function create' : 'c'}() {
182190
${this.builders.create}
183-
${!this.builders.hydrate.isEmpty() && `this.h();`}
191+
${hydrate}
184192
},
185193
`);
186194
}
@@ -190,17 +198,17 @@ export default class Block {
190198
properties.addBlock(`l: @noop,`);
191199
} else {
192200
properties.addBlock(deindent`
193-
l: function claim(nodes) {
201+
${dev ? 'l: function claim' : 'l'}(nodes) {
194202
${this.builders.claim}
195203
${!this.builders.hydrate.isEmpty() && `this.h();`}
196204
},
197205
`);
198206
}
199207
}
200208

201-
if (!this.builders.hydrate.isEmpty()) {
209+
if (this.compiler.options.hydratable && !this.builders.hydrate.isEmpty()) {
202210
properties.addBlock(deindent`
203-
h: function hydrate() {
211+
${dev ? 'h: function hydrate' : 'h'}() {
204212
${this.builders.hydrate}
205213
},
206214
`);
@@ -210,7 +218,7 @@ export default class Block {
210218
properties.addBlock(`m: @noop,`);
211219
} else {
212220
properties.addBlock(deindent`
213-
m: function mount(#target, anchor) {
221+
${dev ? 'm: function mount' : 'm'}(#target, anchor) {
214222
${this.builders.mount}
215223
},
216224
`);
@@ -221,7 +229,7 @@ export default class Block {
221229
properties.addBlock(`p: @noop,`);
222230
} else {
223231
properties.addBlock(deindent`
224-
p: function update(changed, ${this.maintainContext ? '_ctx' : 'ctx'}) {
232+
${dev ? 'p: function update' : 'p'}(changed, ${this.maintainContext ? '_ctx' : 'ctx'}) {
225233
${this.maintainContext && `ctx = _ctx;`}
226234
${this.builders.update}
227235
},
@@ -232,7 +240,7 @@ export default class Block {
232240
if (this.hasIntroMethod) {
233241
if (hasIntros) {
234242
properties.addBlock(deindent`
235-
i: function intro(#target, anchor) {
243+
${dev ? 'i: function intro' : 'i'}(#target, anchor) {
236244
if (${introing}) return;
237245
${introing} = true;
238246
${hasOutros && `${outroing} = false;`}
@@ -244,7 +252,7 @@ export default class Block {
244252
`);
245253
} else {
246254
properties.addBlock(deindent`
247-
i: function intro(#target, anchor) {
255+
${dev ? 'i: function intro' : 'i'}(#target, anchor) {
248256
this.m(#target, anchor);
249257
},
250258
`);
@@ -254,7 +262,7 @@ export default class Block {
254262
if (this.hasOutroMethod) {
255263
if (hasOutros) {
256264
properties.addBlock(deindent`
257-
o: function outro(#outrocallback) {
265+
${dev ? 'o: function outro' : 'o'}(#outrocallback) {
258266
if (${outroing}) return;
259267
${outroing} = true;
260268
${hasIntros && `${introing} = false;`}
@@ -275,7 +283,7 @@ export default class Block {
275283
properties.addBlock(`u: @noop,`);
276284
} else {
277285
properties.addBlock(deindent`
278-
u: function unmount() {
286+
${dev ? 'u: function unmount' : 'u'}() {
279287
${this.builders.unmount}
280288
},
281289
`);
@@ -285,7 +293,7 @@ export default class Block {
285293
properties.addBlock(`d: @noop`);
286294
} else {
287295
properties.addBlock(deindent`
288-
d: function destroy() {
296+
${dev ? 'd: function destroy' : 'd'}() {
289297
${this.builders.destroy}
290298
}
291299
`);

‎test/js/samples/action/expected-bundle.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -154,28 +154,24 @@ function create_main_fragment(component, ctx) {
154154
var a, link_action;
155155

156156
return {
157-
c: function create() {
157+
c() {
158158
a = createElement("a");
159159
a.textContent = "Test";
160-
this.h();
161-
},
162-
163-
h: function hydrate() {
164160
a.href = "#";
165161
link_action = link.call(component, a) || {};
166162
},
167163

168-
m: function mount(target, anchor) {
164+
m(target, anchor) {
169165
insertNode(a, target, anchor);
170166
},
171167

172168
p: noop,
173169

174-
u: function unmount() {
170+
u() {
175171
detachNode(a);
176172
},
177173

178-
d: function destroy$$1() {
174+
d() {
179175
if (typeof link_action.destroy === 'function') link_action.destroy.call(component);
180176
}
181177
};

0 commit comments

Comments
 (0)
Please sign in to comment.