Currently, foo() is not seen in global scope (index.html that uses x-element). Good!
But bar() is from app.js. Not x-element.html contains <script='app.js'></script>.
app.js:
function bar() {}
x-element.html:
<script='app.js'></script>
...
<script>
function foo() { }
</script>