Bug Tracker

Ticket #14459 (closed bug: fixed)

Opened 10 months ago

Last modified 9 months ago

data-* attribute parsing bypasses jQuery.parseJSON (inconsistent with 1.x)

Reported by: gibson042 Owned by:
Priority: low Milestone: 1.11/2.1
Component: data Version: 2.0.3
Keywords: Cc:
Blocking: Blocked by:

Description

2.x data-* attribute parsing directly utilizes JSON.parse, in contrast to both 1.x and the rest of the codebase (i.e.,  ajax). We should probably switch back to jQuery.parseJSON, but could alternatively switch ajax to JSON.parse. I prefer the former mostly for 1.x consistency.

Change History

comment:1 Changed 10 months ago by dmethvin

  • Priority changed from undecided to low
  • Status changed from new to open
  • Component changed from unfiled to data
  • Milestone changed from None to 1.11/2.1

I agree this should all go through the same path.

comment:2 Changed 10 months ago by timmywil

+1 for former

comment:3 follow-up: ↓ 4 Changed 10 months ago by rwaldron

In jQuery 2.x:

(src/ajax/parseJSON.js)

jQuery.parseJSON = JSON.parse;

(src/data.js)

rbrace.test( data ) ? JSON.parse( data ) :

How does it benefit jQuery to go through an alias to the same function?

comment:4 in reply to: ↑ 3 ; follow-up: ↓ 5 Changed 10 months ago by gibson042

Replying to rwaldron:

How does it benefit jQuery to go through an alias to the same function?

Duckpunching in a spy (which is how I came across the  1.x/2.x discrepancy) or a behavior tweak (e.g., for jQuery migrate and #13169).

comment:5 in reply to: ↑ 4 Changed 10 months ago by rwaldron

Replying to gibson042:

Replying to rwaldron:

How does it benefit jQuery to go through an alias to the same function?

Duckpunching in a spy

Seems reasonable enough. +1

comment:6 Changed 9 months ago by Richard Gibson

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

Fix #14459: Use jQuery.parseJSON instead of JSON.parse

Changeset: ced9d155f010bc456745a55a63ca959db9d405d3

Note: See TracTickets for help on using tickets.