Opened 2 months ago

Last modified 9 days ago

#2098 assigned enhancement

'use strict' in JavaScript

Reported by: nicklas Owned by: nicklas
Priority: minor Milestone: BASE 3.12
Component: web Version:
Keywords: Cc:

Description

By adding 'use strict'; to the top of a JavaScript file we can tell the JavaScript engine to not allow some unsafe usage. For example, using a variable without declaring it (for example, due to a typo). This will create safer and more robust code.

For more information see: https://www.w3schools.com/js/js_strict.asp

While the change is simple to implement it requires a lot of testing to check that nothing is broken by it. Luckily it is possible to do this per file (or even per function) so we don't have to do it all at the same time.

Change History (7)

comment:1 Changed 2 months ago by nicklas

  • Milestone changed from BASE Future Release to BASE 3.12
  • Owner changed from everyone to nicklas
  • Status changed from new to assigned

comment:2 Changed 6 weeks ago by nicklas

(In [7419]) References #2098: 'use strict' in JavaScript?

Fixed in the common scripts. Most worked without problems. Only some minor adjustments:

  • js-draw.js: Was using a lot of undeclared variables.
  • main-2.js: Found some unused code. The 'Dates' class used some internal functions that has now been properly declared.
  • tabcontrol-2.js: Found one undeclared variable.

comment:3 Changed 6 weeks ago by nicklas

(In [7420]) References #2098: 'use strict' in JavaScript?

Fixed on the login/logout page and some of the common functionality/utilities for sharing, running plug-ins, etc.

No problems found, except that the "Zoom" page lacked the "Cancel" button.

comment:4 Changed 10 days ago by nicklas

(In [7429]) References #2098: 'use strict' in JavaScript?

Fixed all remaining scripts in the /common. Found a single issue in the "Save columns preset" dialog that caused the preset to be displayed with an incorrect name.

comment:5 Changed 10 days ago by nicklas

(In [7430]) References #2098: 'use strict' in JavaScript?

Fixed in the /info and /my_base folders.

comment:6 Changed 9 days ago by nicklas

(In [7432]) References #2098: 'use strict' in JavaScript?

Fixed /views folder

comment:7 Changed 9 days ago by nicklas

(In [7434]) References #2098: 'use strict' in JavaScript?

Fixed /plugin and /filemanager folders

Note: See TracTickets for help on using tickets.