You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am creating different custom components with each having its own script which gets exported along with component HTML.
The problem I am facing is the export creates same variable name (props, ids, els) for each component type. Below is the example, is there any option to avoid duplicate name for variables in exported script?
<script>
var props = { "i4s5": { "property": 1 }};
var ids = Object.keys(props).map(function (id) { return '#' + id }).join(',');
var els = document.querySelectorAll(ids);
for (var i = 0, len = els.length; i < len; i++) {
var el = els[i];
(function exportScript(props) {
console.log(props);
}.bind(el))(props[el.id]);
}
var props = { "ita2": { "property": 2 }};
var ids = Object.keys(props).map(function (id) { return '#' + id }).join(',');
var els = document.querySelectorAll(ids);
for (var i = 0, len = els.length; i < len; i++) {
var el = els[i];
(function script(props) {
console.log(props);
}.bind(el))(props[el.id]);
}</script>
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi @artf , thanks in advance.
I am creating different custom components with each having its own script which gets exported along with component HTML.
The problem I am facing is the export creates same variable name (props, ids, els) for each component type. Below is the example, is there any option to avoid duplicate name for variables in exported script?
Thanks,
Balaji
Beta Was this translation helpful? Give feedback.
All reactions