Accept more than one endpoint from the same plugin

Bug: Issue 10956
Change-Id: I0e54cc837e35cf88b20b689f4f28fb992ae5fcb5
(cherry picked from commit 486fd92d7d)
This commit is contained in:
Ben Rohlfs
2019-06-04 12:29:07 +02:00
committed by David Pursehouse
parent 2be2df6581
commit fce11672b6
2 changed files with 20 additions and 4 deletions

View File

@@ -112,7 +112,8 @@
},
_initModule({moduleName, plugin, type, domHook}) {
if (this._initializedPlugins.get(plugin.getPluginName())) {
const name = plugin.getPluginName() + '.' + moduleName;
if (this._initializedPlugins.get(name)) {
return;
}
let initPromise;
@@ -125,10 +126,9 @@
break;
}
if (!initPromise) {
console.warn('Unable to initialize module' +
`${moduleName} from ${plugin.getPluginName()}`);
console.warn('Unable to initialize module ' + name);
}
this._initializedPlugins.set(plugin.getPluginName(), true);
this._initializedPlugins.set(name, true);
initPromise.then(el => {
domHook.handleInstanceAttached(el);
this._domHooks.set(el, domHook);

View File

@@ -127,6 +127,22 @@ limitations under the License.
});
});
test('two modules', done => {
plugin.registerCustomComponent('banana', 'mod-one');
plugin.registerCustomComponent('banana', 'mod-two');
flush(() => {
const element =
container.querySelector('gr-endpoint-decorator[name="banana"]');
const module1 = Polymer.dom(element.root).children.find(
element => element.nodeName === 'MOD-ONE');
assert.isOk(module1);
const module2 = Polymer.dom(element.root).children.find(
element => element.nodeName === 'MOD-TWO');
assert.isOk(module2);
done();
});
});
test('late param setup', done => {
const element =
container.querySelector('gr-endpoint-decorator[name="banana"]');