Is the "slot" a fallback word in the new version of ECMAScript?

This is a problem with google chrome version 53.0.2785.101 (64-bit). I tried to run a simple html file and it gives the error “slot.testFun is not a function” when I used the word “slot”.

<html>
<head>
    <title>TEST</title>
</head>
<body>
    <a href="#" onclick="slot.testFun();">Click Here</a>

    <script type="text/javascript">
        var slot = {
            testFun: function(){
                console.log('clicked');
            }
        }
    </script>
</body>
</html>

There are no conflicts with this variable in our code. It is simply a browser that does not allow the variable name in this latest version.

If you use any name other than the word "slot", it works fine.

+4
source share
1 answer

This is not an ECMAScript problem, this is a DOM problem.

slot, onclick with, this.slot.testFun(), slot ( ), .

slot DOM, slot Chrome 53. Chrome 52 , , .

: . DOM. DOM.

<a href="#">Click Here</a>

<script type="text/javascript">
    var slot = {
        testFun: function(){
            console.log('clicked');
        }
    }
    document.querySelector("a").addEventListener("click", slot.testFun);
</script>
+7

Source: https://habr.com/ru/post/1654344/


All Articles