Skip to content

Commit

Permalink
Time: cache options needed by parse (#8933)
Browse files Browse the repository at this point in the history
  • Loading branch information
kurkle committed Apr 18, 2021
1 parent c107f89 commit e1404ac
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/scales/scale.time.js
Expand Up @@ -48,8 +48,7 @@ function parse(scale, input) {
}

const adapter = scale._adapter;
const options = scale.options.time;
const {parser, round, isoWeekday} = options;
const {parser, round, isoWeekday} = scale._parseOpts;
let value = input;

if (typeof parser === 'function') {
Expand Down Expand Up @@ -217,6 +216,7 @@ export default class TimeScale extends Scale {
this._majorUnit = undefined;
this._offsets = {};
this._normalized = false;
this._parseOpts = undefined;
}

init(scaleOpts, opts) {
Expand All @@ -229,6 +229,12 @@ export default class TimeScale extends Scale {
// missing formats on update
mergeIf(time.displayFormats, adapter.formats());

this._parseOpts = {
parser: time.parser,
round: time.round,
isoWeekday: time.isoWeekday
};

super.init(scaleOpts);

this._normalized = opts.normalized;
Expand Down

0 comments on commit e1404ac

Please sign in to comment.