Reputation: 22064
In the following code, I'm not using any 'with statement', but when I set the breakpoint, it gives me the error:
SyntaxError: 'with' statements are not valid in strict mode
(function () {
'use strict';
function addItem() {
var orderListElement, newLi, childCount;
orderListElement = document.getElementById('orderList');
newLi = document.createElement('li');
childCount = orderListElement.children.length;
newLi.textContent = 'new item ';
orderListElement.appendChild(newLi);
}
function deleteItem() {
var orderListElement, lastLi;
orderListElement = document.getElementById('orderList');
lastLi = orderListElement.lastChild;
orderListElement.removeChild(lastLi);
}
function registHandler() {
var addItemButton, deleteItemButton;
addItemButton = document.getElementById('addItem');
deleteItemButton = document.getElementById('deleteItem');
addItemButton.addEventListener('click', addItem, false);
deleteItemButton.addEventListener('click', deleteItem, false);
}
window.addEventListener('load', registHandler, false);
}());
That's so annoying.
Upvotes: 2
Views: 356
Reputation: 9743
This appears to be a known issue with Safari: https://bugs.webkit.org/show_bug.cgi?id=65829
To reproduce the Error, you simply need to type any code into the console while stopped at a breakpoint and while in strict mode.
Here's the code from the bug report:
(function(){
"use strict";
debugger;
})();
So when you're at the breakpoint, go to the console and type 2+3
(or any expression), and you'll get the Error.
Upvotes: 1