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

Prevent execution of script in knockout #2570

Open
akv31 opened this issue May 20, 2021 · 3 comments
Open

Prevent execution of script in knockout #2570

akv31 opened this issue May 20, 2021 · 3 comments

Comments

@akv31
Copy link

akv31 commented May 20, 2021

jQueryInstance(node)['html'](html);

While debugging. My html at this point is

<div>Hello World<script>console.log('hi there');</script></div>

The browser renders 'Hello World' and also executes the script. How can we prevent the script from executing.

@ghost
Copy link

ghost commented Jul 21, 2021

It has nothing to do with knockout itself. It is normal browser behavior. If you set the the "html" Attribute the string will be rendered in the DOM. You should use the text binding.
This behavior is well documented: https://knockoutjs.com/documentation/html-binding.html

@the-djmaze
Copy link

the-djmaze commented Jul 28, 2021

<template><div>Hello World<script>console.log('hi there');</script></div></template>

This doesn't.

@ghost
Copy link

ghost commented Jul 29, 2021

@the-djmaze but then it is a template. Isn't it then a complete different use case?

I think there is no probleme here. We don't know what @akv31 want. This issue should be closed.

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

2 participants