manolo / gwt-api-generator

Generator for creating GWT JSInterop clients from Polymer Web Components
Apache License 2.0
50 stars 24 forks source link

POLYMER , Import href #37

Closed lilletech closed 9 years ago

lilletech commented 9 years ago

When you're adding widgets on the fly programmatically for the first time (ex : new PaperButton x5 in a for) the import is imported multiple time because the href is not fully loaded between each instanciation. urlImported.add(href); should be added directly to avoid the issue. Maybe remove it if the script fail to load ?

public static void importHref(String hrefOrTag, final Function ok, Function err) { if (!hrefOrTag.startsWith("http")) { // It's a tag if (hrefOrTag.matches("[\w-]+")) { hrefOrTag = hrefOrTag + "/" + hrefOrTag + ".html"; } // It's not prefixed with the bower_components convention if (!hrefOrTag.startsWith("bower_components")) { hrefOrTag = "bower_components/" + hrefOrTag; } hrefOrTag = GWT.getModuleBaseForStaticFiles() + hrefOrTag; } if (!urlImported.contains(hrefOrTag)) { final String href = hrefOrTag; importHrefImpl(href, new Function() { public Object call(Object arg) { // Don't update the list until the import is actually loaded urlImported.add(href); if (ok != null) { ok.call(arg); } return null; } }, err); } else if (ok != null) { ok.call(hrefOrTag); } }

lilletech commented 9 years ago

you can see the link import are imported multiple times in the demo http://vaadin.github.io/gwt-polymer-elements/demo/#paper/ButtonSample