Forum Moderators: open

Message Too Old, No Replies

Parsing error: Octal literal in strict

         

csdude55

7:15 pm on Jul 30, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Any clue what this means?

My Javascript file works fine in Chrome but is dying in IE9. I used validatejavascript.com, though, and this is the only error it gave... unfortunately for me, I have no clue what it means.

This is the section of code that's throwing an error:

var cssArr = [
'display',
'float',
'white-space',
'width',
'height',
'min-width',
'min-height',
'padding(-\\w+)?',
'margin(-\\w+)?',
'position',
'top',
'bottom',
'left',
'right',
'orphans',
'widows',
'text-align',
'text-indent',
'word(-\\w+)?',
'overflow(-\\w+)?',
'box-sizing',
'font-variant(-\\w+)?',
'background(-\\w+)?',

'-webkit-[\\w-]',
'-ms-[\\w-]',
'-moz-[\\w-]',
'-o-[\\w-]'
];

var style_match;

for (var i = 0; i < cssArr.length; i++) {
// the following line is line 287
style_match = new RegExp("style=(\"|')([\\w\\s:;-])*" + cssArr[i] + "\\s*:\\s*[\\w-]+?[;>\1]", 'gi');

while (style_match.test(a))
a = a.replace(style_match, 'style=$1$2');
}


And the complete error is:

287:94 error Parsing error: Octal literal in strict mode 285 | 286 | for (var i = 0; i < cssArr.length; i++) { > 287 | style_match = new RegExp("style=(\"|')([\\w\\s:;-])*" + cssArr[i] + "\\s*:\\s*[\\w-]+?[;>\1]", 'gi'); | ^ 288 | 289 | while (style_match.test(a)) 290 | a = a.replace(style_match, 'style=$1$2');


Any clue?

robzilla

7:53 pm on Jul 30, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The validator seems to be tripping over \1, which it considers an octal literal for some reason. I'd ignore it.

Maybe try the IE9 Developer Tools to debug your script.

csdude55

8:14 pm on Jul 30, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thanks, Rob. I haven't used IE in years, so it took me awhile to figure out their debugger.

It looks like it's choking on another section that works everywhere else. I'm going to dig through it, and if I can't figure it out I'll create a new thread.