Skip to content

Commit

Permalink
Bugfix: Craete new instance of iron-request (#107)
Browse files Browse the repository at this point in the history
iron-request instances can not be re-used.
This fix removes iron-request from the template and dynamically creates
a new instance for each request.
  • Loading branch information
timeu authored and ebidel committed Jun 15, 2016
1 parent a0a02ae commit bf84b5b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions google-chart.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
<dom-module id="google-chart">
<link rel="import" type="css" href="google-chart.css">
<template>
<iron-request id="xhr"></iron-request>
<div id="chartdiv"></div>
</template>
</dom-module>
Expand Down Expand Up @@ -454,7 +453,8 @@
var dataTable;
if (typeof data == 'string' || data instanceof String) {
// Load data asynchronously, from external URL.
dataTable = this.$.xhr.send({url: data, handleAs: 'json'})
var request = /** @type {!IronRequestElement} */ (document.createElement('iron-request'));
dataTable = request.send({url: data, handleAs: 'json'})
.then(function(xhr) {
return xhr.response;
});
Expand Down
4 changes: 4 additions & 0 deletions test/basic-tests.html
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@
});
});
});
test('multiple calls to JSON URL', function(done) {
setDataAndWaitForRender('test-data-array.json', done);
setDataAndWaitForRender('test-data-object.json', done);
});
});
});
</script>
Expand Down

0 comments on commit bf84b5b

Please sign in to comment.