Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#14930 closed defect (fixed)

JsonRest tries to assign properties to a frozen object

Reported by: ben hockey Owned by: Kris Zyp
Priority: high Milestone: 1.8
Component: Data Version: 1.7.2
Keywords: Cc:
Blocked By: Blocking:

Description

in query, JsonRest tries to assign results.total to a promise. in browsers that support Object.freeze this will fail (silently). QueryResults uses delegate to allow assigning properties to a frozen promise, maybe JsonRest could do the same.

Change History (5)

comment:1 Changed 7 years ago by ben hockey

Priority: undecidedhigh

comment:2 Changed 7 years ago by ben hockey

#14928 is a duplicate of this ticket.

comment:3 Changed 7 years ago by ben hockey

a possible patch:

  • store/JsonRest.js

     
    1 define(["../_base/xhr", "../json", "../_base/declare", "./util/QueryResults"
    2 ], function(xhr, JSON, declare, QueryResults) {
     1define(["../_base/xhr", "../json", "../_base/declare", "./util/QueryResults", "dojo/_base/lang"
     2], function(xhr, JSON, declare, QueryResults, lang) {
    33  //  module:
    44  //    dojo/store/JsonRest
    55  //  summary:
     
    141141                               query += ")";
    142142                       }
    143143               }
    144                var results = xhr("GET", {
     144               var results = lang.delegate(xhr("GET", {
    145145                       url: this.target + (query || ""),
    146146                       handleAs: "json",
    147147                       headers: headers
    148                });
     148               }));
    149149               results.total = results.then(function(){
    150150                       var range = results.ioArgs.xhr.getResponseHeader("Content-Range");
    151151                       return range && (range=range.match(/\/(.*)/)) && +range[1];

comment:4 Changed 7 years ago by Kris Zyp

Resolution: fixed
Status: newclosed

The return value of xhr(), in the latest trunk is a deferred and not a direct frozen promise, so this is no longer an issue.

comment:5 Changed 7 years ago by Kris Zyp

Milestone: tbd1.8
Note: See TracTickets for help on using tickets.