How do I access an element in the local DOM if the id has a dash?
<dom-module id="name-tag">
<template>
<div id="offices-list"></div>
</template>
<script>
Polymer({
is: "name-tag",
ready: function() {
var div_new = document.createElement('div');
Polymer.dom(this.$.officesList).appendChild(div_new);
}
});
</script>
</dom-module>
The error message is currently thrown:
Uncaught HierarchyRequestError: Failed to execute 'appendChild' on 'Node': Only one document element allowed.
However, if I change the id from "office-list" to "officeList" it works. How can I do the same while keeping the id as it is, i.e. With a dash?
+3
source to share
1 answer
This is an open-ended question / improvement with Polymer:
https://github.com/Polymer/polymer/issues/1747 also https://github.com/Polymer/polymer/issues/150
Work around - use this.$['offices-list']
+8
source to share