Opened 19 months ago

Closed 14 months ago

Last modified 14 months ago

#2098 closed enhancement (fixed)

'use strict' in JavaScript

Reported by: Nicklas Nordborg Owned by: Nicklas Nordborg
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 18 months ago by Nicklas Nordborg

Milestone: BASE Future ReleaseBASE 3.12
Owner: changed from everyone to Nicklas Nordborg
Status: newassigned

comment:2 Changed 18 months ago by Nicklas Nordborg

(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 18 months ago by Nicklas Nordborg

(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 17 months ago by Nicklas Nordborg

(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 17 months ago by Nicklas Nordborg

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

Fixed in the /info and /my_base folders.

comment:6 Changed 17 months ago by Nicklas Nordborg

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

Fixed /views folder

comment:7 Changed 17 months ago by Nicklas Nordborg

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

Fixed /plugin and /filemanager folders

comment:8 Changed 15 months ago by Nicklas Nordborg

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

Fixed /biomaterials folder

comment:9 Changed 15 months ago by Nicklas Nordborg

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

Fixed /lims folder

comment:10 Changed 14 months ago by Nicklas Nordborg

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

Fixed some in the /admin folder.

comment:11 Changed 14 months ago by Nicklas Nordborg

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

Fixed more in the /admin folder.

comment:12 Changed 14 months ago by Nicklas Nordborg

(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 14 months ago by Nicklas Nordborg

Resolution: fixed
Status: assignedclosed

comment:14 Changed 14 months ago by Nicklas Nordborg

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

Found one more undefined variable.

Note: See TracTickets for help on using tickets.