Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.9] on-click="kickAction()" #1552

Closed
gertcuykens opened this issue May 16, 2015 · 3 comments
Closed

[0.9] on-click="kickAction()" #1552

gertcuykens opened this issue May 16, 2015 · 3 comments

Comments

@gertcuykens
Copy link

Why did you remove () ?
Why not on-click="kickAction()" ?
We have been using () sins 1990 :P

<template>

  <button on-click="kickAction()">Kick Me</button>

</template>

<script>

  Polymer({

    is: 'x-custom',

    kickAction: function() {
      alert('Ow!');
    }

  });

</script>
<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Click me</button>

<p id="demo"></p>

<p>A function is triggered when the button is clicked. The function outputs some text in a p element with id="demo".</p>

<script>
function myFunction() {
    document.getElementById("demo").innerHTML = "Hello World";
}
</script>

</body>
</html>
@zoechi
Copy link

zoechi commented May 16, 2015

I think this only makes sense when passing arguments is supported.
IMHO if arguments aren't supported in the expression, then the braces shouldn't be used.
kickAction means that we pass the function kickAction to Polymer to be called by Polymer as appropriate (with arguments if applicable), kickAction() indicates to me the expression kickAction() should be evaluated.

@sjmiles
Copy link
Contributor

sjmiles commented May 16, 2015

The code inside of onclick attribute is evaluated directly as JavaScript. This is a major security vulnerability in HTML and it's use is strongly discouraged in all circles.

Polymer doesn't evaluate code from HTML, it instead uses the attribute to map a method name to an event.

@sjmiles sjmiles closed this as completed May 16, 2015
@gertcuykens
Copy link
Author

Ok fair enough I agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants