Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Octal literals are not allowed in strict mode

I am using Angular 2.

When I use this in SCSS file, it works well.

.text::after {
  content: "\00a0\00a0";
}

However, when I move it in

styles: [``]

It shows:

Uncaught SyntaxError: Octal literals are not allowed in strict mode.

I know codes in styles: [``] needs to be CSS codes.

And I tried

styles: [`
    .text::after {
      content: "  ";
    }
`]

But then the screen shows    directly. How can I write it correctly?

like image 753
Hongbo Miao Avatar asked Apr 27 '16 01:04

Hongbo Miao


People also ask

What is octal literal?

An octal integer literal begins with the digit 0 and contains any of the digits 0 through 7.

What are octal literals in Javascript?

Octal literals start with 0o followed by a sequence of numbers between 0 and 7. Binary literals start with 0b followed by a sequence of number 0 and 1.

What are octal literals in Python?

Python - Hexadecimal, octal, and binary literals Octal literals start with a leading 0o or 0O (zero and lower- or uppercase letter o), followed by a string of digits (0-7). In 2. X, octal literals can also be coded with just a leading 0, but not in 3.

What is octal escape?

An octal escape sequence is a backslash followed by one, two, or three octal digits (0-7). It matches a character in the target sequence with the value specified by those digits. If all the digits are '0' the sequence is invalid.


2 Answers

You need to escape it

.text::after {
  content: "\\00a0\\00a0";  // now it's just a simple plain string
}

"use strict" is a new feature introduced in JavaScript 1.8.5 (ECMAScript version 5).

In which,

  • Octal numeric literals are not allowed
  • Escape characters are not allowed
  • see more...
like image 184
Ankit Singh Avatar answered Oct 16 '22 15:10

Ankit Singh


Or you can add u (unicode) before the \.

  .text::after {
    content: "\u00a0\u00a0"
  }
like image 2
Nixie Avatar answered Oct 16 '22 15:10

Nixie