correctly weed out benign calls inside attributes

This commit is contained in:
Erik Krogh Kristensen
2019-11-11 15:17:57 +01:00
parent b0fecbce28
commit 67b38ed301
3 changed files with 23 additions and 1 deletions

View File

@@ -1,3 +1,4 @@
| tst.html:19:28:19:40 | addHandlers() | the $@ does not return anything, yet the return value is used. | tst.html:5:7:12:7 | functio ... } | function addHandlers |
| tst.js:20:17:20:33 | onlySideEffects() | the $@ does not return anything, yet the return value is used. | tst.js:11:5:13:5 | functio ... )\\n } | function onlySideEffects |
| tst.js:24:13:24:29 | onlySideEffects() | the $@ does not return anything, yet the return value is used. | tst.js:11:5:13:5 | functio ... )\\n } | function onlySideEffects |
| tst.js:30:20:30:36 | onlySideEffects() | the $@ does not return anything, yet the return value is used. | tst.js:11:5:13:5 | functio ... )\\n } | function onlySideEffects |

View File

@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<script>
function addHandlers () {
const cdoc = document.getElementById('container').contentDocument;
if (cdoc) {
const scriptelm = cdoc.createElement('script');
scriptelm.src = '../handlers.js';
cdoc.getElementsByTagName('head')[0].appendChild(scriptelm);
}
}
</script>
</head>
<body>
<object id="container" data="editor/svg-editor.html" onload="addHandlers()"></object>
<a href="javascript:addHandlers()">Foo</a>
<div onclick="addHandlers()">Click me</div>
<div onclick="console.log(addHandlers() + 3)">Click me</div> <!-- NOT OK! -->
</body>
</html>