Skip to content

Commit 7688ecb

Browse files
committed
Track initializers already seen (fixes #21439)
R=jakemac@google.com Review URL: https://codereview.chromium.org//700733002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41499 260f80e4-7a28-3924-810f-c04153c831b5
1 parent b388054 commit 7688ecb

File tree

3 files changed

+48
-24
lines changed

3 files changed

+48
-24
lines changed

pkg/polymer/lib/src/build/script_compactor.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,19 @@ class _ScriptCompactor extends PolymerTransformer {
249249
// Process all classes and top-level functions to include initializers,
250250
// register custom elements, and include special fields and methods in
251251
// custom element classes.
252+
var functionsSeen = new Set<FunctionElement>();
253+
var classesSeen = new Set<ClassElement>();
252254
for (var id in entryLibraries) {
253255
var lib = resolver.getLibrary(id);
254256
for (var fun in _visibleTopLevelMethodsOf(lib)) {
257+
if (functionsSeen.contains(fun)) continue;
258+
functionsSeen.add(fun);
255259
_processFunction(fun, id);
256260
}
257261

258262
for (var cls in _visibleClassesOf(lib)) {
263+
if (classesSeen.contains(cls)) continue;
264+
classesSeen.add(cls);
259265
_processClass(cls, id, recorder);
260266
}
261267
}
@@ -824,8 +830,7 @@ List<FunctionElement> _visibleTopLevelMethodsOf(LibraryElement lib) {
824830
var result = [];
825831
result.addAll(lib.units.expand((u) => u.functions));
826832
for (var e in lib.exports) {
827-
var exported = e.exportedLibrary.units
828-
.expand((u) => u.functions).toList();
833+
var exported = e.exportedLibrary.units.expand((u) => u.functions).toList();
829834
_filter(exported, e.combinators);
830835
result.addAll(exported);
831836
}

pkg/polymer/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: polymer
2-
version: 0.15.1+3
2+
version: 0.15.1+4
33
author: Polymer.dart Authors <web-ui-dev@dartlang.org>
44
description: >
55
Polymer.dart is a new type of library for the web, built on top of Web

pkg/polymer/test/build/script_compactor_test.dart

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,16 @@ initializerTests(phases) {
245245
'<!DOCTYPE html><html><head>'
246246
'</head><body><div></div>',
247247
'a|web/test.html._data':
248-
expectedData(['web/a.dart', 'web/b.dart', 'web/c.dart', 'web/d.dart']),
248+
expectedData(['web/a.dart', 'web/b.dart', 'web/c.dart',
249+
'web/i.dart', 'web/j.dart', 'web/d.dart']),
249250
'a|web/d.dart':
250251
'library d;\n'
251252
'import "package:polymer/polymer.dart";\n'
252253
'main(){}\n@initMethod mD(){}',
253254

254255
'a|web/a.dart':
255256
'import "package:polymer/polymer.dart";\n'
257+
'export "i.dart" hide mI2;\n'
256258
'@initMethod mA(){}\n',
257259

258260
'a|web/b.dart':
@@ -296,6 +298,15 @@ initializerTests(phases) {
296298
'@initMethod mH1(){}\n'
297299
'@CustomTag("x-h2") class XH2 extends PolymerElement {}\n'
298300
'@initMethod mH2(){}\n',
301+
302+
'a|web/i.dart':
303+
'import "package:polymer/polymer.dart";\n'
304+
'@CustomTag("x-i") class XI extends PolymerElement {}\n'
305+
'@initMethod mI1(){}\n'
306+
'@initMethod mI2(){}\n',
307+
308+
'a|web/j.dart':
309+
'export "a.dart";\n',
299310
}, {
300311
'a|web/test.html':
301312
'<!DOCTYPE html><html><head></head><body><div></div>'
@@ -308,36 +319,43 @@ initializerTests(phases) {
308319
import 'a.dart' as i0;
309320
import 'b.dart' as i1;
310321
import 'c.dart' as i2;
311-
import 'd.dart' as i3;
322+
import 'i.dart' as i3;
323+
import 'j.dart' as i4;
324+
import 'd.dart' as i5;
312325
${DEFAULT_IMPORTS.join('\n')}
313-
import 'e.dart' as smoke_0;
326+
import 'i.dart' as smoke_0;
314327
import 'package:polymer/polymer.dart' as smoke_1;
315-
import 'f.dart' as smoke_2;
316-
import 'g.dart' as smoke_3;
317-
import 'h.dart' as smoke_4;
318-
import 'c.dart' as smoke_5;
328+
import 'e.dart' as smoke_2;
329+
import 'f.dart' as smoke_3;
330+
import 'g.dart' as smoke_4;
331+
import 'h.dart' as smoke_5;
332+
import 'c.dart' as smoke_6;
319333
320334
void main() {
321335
useGeneratedCode(new StaticConfiguration(
322336
checkedMode: false,
323337
parents: {
324-
smoke_5.XC1: smoke_1.PolymerElement,
325-
smoke_5.XC2: smoke_1.PolymerElement,
326-
smoke_0.XE: smoke_1.PolymerElement,
327-
smoke_2.XF1: smoke_1.PolymerElement,
328-
smoke_3.XG2: smoke_1.PolymerElement,
329-
smoke_4.XH1: smoke_1.PolymerElement,
338+
smoke_6.XC1: smoke_1.PolymerElement,
339+
smoke_6.XC2: smoke_1.PolymerElement,
340+
smoke_2.XE: smoke_1.PolymerElement,
341+
smoke_3.XF1: smoke_1.PolymerElement,
342+
smoke_4.XG2: smoke_1.PolymerElement,
343+
smoke_5.XH1: smoke_1.PolymerElement,
344+
smoke_0.XI: smoke_1.PolymerElement,
330345
},
331346
declarations: {
332-
smoke_5.XC1: {},
333-
smoke_5.XC2: {},
334-
smoke_0.XE: {},
335-
smoke_2.XF1: {},
336-
smoke_3.XG2: {},
337-
smoke_4.XH1: {},
347+
smoke_6.XC1: {},
348+
smoke_6.XC2: {},
349+
smoke_2.XE: {},
350+
smoke_3.XF1: {},
351+
smoke_4.XG2: {},
352+
smoke_5.XH1: {},
353+
smoke_0.XI: {},
338354
}));
339355
configureForDeployment([
340356
i0.mA,
357+
i0.mI1,
358+
() => Polymer.register('x-i', i0.XI),
341359
i1.mB,
342360
i1.mE,
343361
i1.mF1,
@@ -348,9 +366,10 @@ initializerTests(phases) {
348366
() => Polymer.register('x-h1', i1.XH1),
349367
() => Polymer.register('x-c1', i2.XC1),
350368
() => Polymer.register('x-c2', i2.XC2),
351-
i3.mD,
369+
i3.mI2,
370+
i5.mD,
352371
]);
353-
i3.main();
372+
i5.main();
354373
}
355374
'''.replaceAll('\n ', '\n'),
356375
}, null);

0 commit comments

Comments
 (0)