Opened 9 months ago

Closed 4 months ago

Last modified 3 months ago

#2098 closed enhancement (fixed)

'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 (14)

comment:1 Changed 8 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 8 months 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 8 months 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 7 months 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 7 months ago by nicklas

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

Fixed in the /info and /my_base folders.

comment:6 Changed 7 months ago by nicklas

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

Fixed /views folder

comment:7 Changed 7 months ago by nicklas

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

Fixed /plugin and /filemanager folders

comment:8 Changed 5 months ago by nicklas

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

Fixed /biomaterials folder

comment:9 Changed 5 months ago by nicklas

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

Fixed /lims folder

comment:10 Changed 4 months ago by nicklas

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

Fixed some in the /admin folder.

comment:11 Changed 4 months ago by nicklas

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

Fixed more in the /admin folder.

comment:12 Changed 4 months ago by nicklas

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

Fixed remaining scripts in the /admin folder. I think this was the last ones.

comment:13 Changed 4 months ago by nicklas

  • Resolution set to fixed
  • Status changed from assigned to closed

comment:14 Changed 3 months ago by nicklas

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

Found one more undefined variable.

Note: See TracTickets for help on using tickets.