U3, HTML5: SetVar and 'equal to, ignore case' cause JS error

Jun 10, 2013

Summary:

In Update 3, SetVar will try to convert strings to numbers when setting text variables.  If a case insensitive compare is done with a trigger (i.e., a trigger has an 'equal to, ignore case' condition), a JavaScript error occurs and the behavior breaks.  This occurs with HTML5 affects both Safari and Chrome.  It's unknown whether it affects Flash.

The error is:

Uncaught TypeError: Object 6 has no method 'toLowerCase'

Full Description:

I recently updated to Update 3 and encountered a regression issue regarding the use of 'equal to, ignore case' on a variable set via SetVar.

I have set up a slide with:

  1. A text variable (TextVar1) with a default value of -1.
  2. A radio button labeled Value: -1.
  3. A radio button labeled Value: 6.
  4. A trigger that changes the state of the first radio button to 'Selected' when TextVar1 changes to '-1'.
  5. A trigger that changes the state of the second radio button to 'Selected' when TextVar1 changes to '6'.
  6. A button that uses JavaScript and SetVar to set TextVar1 to '-1'.  It also prints a little debugging info to the browser's JavaScript console.
  7. A button that uses JavaScript and SetVar to set TextVar1 to '6'.  It also prints a little debugging info to the browser's JavaScript console.

In short: When a button is pressed, TextVar1 is set to a value, which causes the corresponding radio button to be selected.

I have 2 versions of this slide:

  1. The triggers in steps 4 and 5 use 'equal to'.
  2. The triggers in steps 4 and 5 use 'equal to, ignore case'.

Since the text variable is only being set to numeric representation (i.e., no characters have both upper and lower case variants), the behavior of the 2 slides should be identical.

I then did the following:

  1. Published for the web.  All of the check boxes were selected so as to generate the HTML5 version.
  2. Opened the story_html5.html file in the latest version of Google Chrome.  (27.0.1453.110 m)
  3. Opened the JavaScript console.
  4. When I press the buttons on the 'equal to' version of the slide, I get the expected debugging information.
  5. When I press the buttons on the 'equal to, ignore case' version of the slide, I get JavaScript errors.

Note:

Update 2 had a related issue where using SetVar to set the value of a Text variable to a number, then doing a case insensitive compare in a trigger, would generate the same error.  However, setting it to a string version worked.

E.g.,

GetPlayer().SetVar('foo', 1) - causes errors in both Update 2 and Update 3.

GetPlayer().SetVar('foo', '1') - works in Update 2 but not in Update 3.

GetPlayer().SetVar('foo', String(1)) - works is Update 2 but not in Update 3

6 Replies
Sam Hammond

Hey there, 

It's me again, kicking up really old posts! :) 

Wanted to check about whether this was ever solved in subsequent updates (we're now on U10), or if this is "intended behavior." I'm noticing a similar error in devtools when running an HTML5 textfill activity with "ignore case" evaluations: 

player_compiled.js:297 Uncaught TypeError: l.toLowerCase is not a function

I'm hoping that switching out the evals to a strict "equal to" in cases where the textfill I'm looking for is a number will do the trick, but I have yet to get it working. 

Sam Hammond

Hi Leslie, 

Sorry for the delay in getting back to you. No, I'm using the latest and greatest version of SL2. It still appears that this is an issue there.

I was able to get everything working by changing all of the "ignore case" triggers that were evaluating non-strings (i.e. numbers) to a strict "equal to" or "not equal to." However, it'd be really nice if the player_complied.js could handle that rather than leave it up to the users to select the right kind of trigger. It's especially nefarious because the logic is less strict in the flash output; it won't fail there but it will fail in HTML5. 

This discussion is closed. You can start a new discussion or contact Articulate Support.