jquery / jquery/jquery-ui

jQuery UI v1.13 getNumber RegExp not working for dateRange

Open
#2,264 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Behavior shared with 1.12 Comp: Datepicker Needs info
Dominant language
JavaScript
Stars
11.3k
Forks
5.2k
PR merge metrics
No merged PRs in 30d

Description

Description

Due to the changes introduced in jQuery UI v1.13 for function getNumber selecting dateRange from date clear out to date

getNumber = function( match ) {
      var isDoubled = lookAhead( match ),
      size = ( match === "@" ? 14 : ( match === "!" ? 20 :
      ( match === "y" && isDoubled ? 4 : ( match === "o" ? 3 : 2 ) ) ) ),
      minSize = ( match === "y" ? size : 1 ),
      digits = new RegExp( "^\\d{" + minSize + "," + size + "}" ),
      num = value.substring( iValue ).match( digits );
      if ( !num ) {
      throw "Missing number at position " + iValue;
      }
      iValue += num[ 0 ].length;
      return parseInt( num[ 0 ], 10 );
},
RCA

Updating jQuery UI from v1.9.2 to v1.13.2 changes the behaviour of getNumber function which extract a number from the string value.
The issue was also observed when switching to version 1.12.1

Solution

changing
v1.13.2
digits = new RegExp( "^\\d{" + minSize + "," + size + "}" ),
to v1.9.2
digits = new RegExp('^\\d{1,' + size + '}'),

will fix the issue.

Screenshot
wwwwww Screenshot 2024-06-18 at 1 37 05 AM
Affected Product

Magento -> Admin -> Reports -> Products -> Ordered

Error

Missing number at position 5

Link to test case

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the dateRange parsing path and inspect the getNumber function, comparing its behavior between jQuery UI 1.9.2 and 1.13.2. Reproduce the Magento admin date-range case and verify that selecting a from date preserves the to date without producing “Missing number at position 5”.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, jquery
Domain
frontend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.