]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Time: cache options needed by parse (#8933)
authorJukka Kurkela <jukka.kurkela@gmail.com>
Sun, 18 Apr 2021 11:30:54 +0000 (14:30 +0300)
committerGitHub <noreply@github.com>
Sun, 18 Apr 2021 11:30:54 +0000 (07:30 -0400)
src/scales/scale.time.js

index c528a3890470c459cada880760f2a3e5638ac248..18da79aa4596c1092d4501bf97d5117e6a329d07 100644 (file)
@@ -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') {
@@ -217,6 +216,7 @@ export default class TimeScale extends Scale {
     this._majorUnit = undefined;
     this._offsets = {};
     this._normalized = false;
+    this._parseOpts = undefined;
   }
 
   init(scaleOpts, opts) {
@@ -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;