You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by su...@apache.org on 2020/05/07 14:20:33 UTC
[incubator-echarts] branch next updated: fix: clarify comments.
This is an automated email from the ASF dual-hosted git repository.
sushuang pushed a commit to branch next
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git
The following commit(s) were added to refs/heads/next by this push:
new 1785081 fix: clarify comments.
1785081 is described below
commit 1785081e5407bd61b1d0c882a86331f6c5ad0057
Author: 100pah <su...@gmail.com>
AuthorDate: Thu May 7 22:19:58 2020 +0800
fix: clarify comments.
---
src/model/Component.ts | 14 +++++++++-----
src/model/Model.ts | 14 +++++++++-----
src/model/Series.ts | 14 +++++++++-----
src/view/Chart.ts | 14 +++++++++-----
src/view/Component.ts | 14 +++++++++-----
5 files changed, 45 insertions(+), 25 deletions(-)
diff --git a/src/model/Component.ts b/src/model/Component.ts
index 0d2b0c0..94419c6 100644
--- a/src/model/Component.ts
+++ b/src/model/Component.ts
@@ -47,11 +47,15 @@ const inner = makeInner<{
class ComponentModel<Opt extends ComponentOption = ComponentOption> extends Model<Opt> {
- // [Caution]: for compat the previous "class extend"
- // publich and protected fields must be initialized on
- // prototype rather than in constructor. Otherwise the
- // subclass overrided filed will be overwritten by this
- // class. That is, they should not be initialized here.
+ // [Caution]: Becuase this class or desecendants can be used as `XXX.extend(subProto)`,
+ // the class members must not be initialized in constructor or declaration place.
+ // Otherwise there is bad case:
+ // class A {xxx = 1;}
+ // enableClassExtend(A);
+ // class B extends A {}
+ // var C = B.extend({xxx: 5});
+ // var c = new C();
+ // console.log(c.xxx); // expect 5 but always 1.
/**
* @readonly
diff --git a/src/model/Model.ts b/src/model/Model.ts
index 0967877..e743be4 100644
--- a/src/model/Model.ts
+++ b/src/model/Model.ts
@@ -46,11 +46,15 @@ type Value<Opt, R> = Opt extends Dictionary<any>
class Model<Opt extends ModelOption = ModelOption> { // TODO: TYPE use unkown insteadof any?
- // [Caution]: for compat the previous "class extend"
- // publich and protected fields must be initialized on
- // prototype rather than in constructor. Otherwise the
- // subclass overrided filed will be overwritten by this
- // class. That is, they should not be initialized here.
+ // [Caution]: Becuase this class or desecendants can be used as `XXX.extend(subProto)`,
+ // the class members must not be initialized in constructor or declaration place.
+ // Otherwise there is bad case:
+ // class A {xxx = 1;}
+ // enableClassExtend(A);
+ // class B extends A {}
+ // var C = B.extend({xxx: 5});
+ // var c = new C();
+ // console.log(c.xxx); // expect 5 but always 1.
/**
* @readOnly
diff --git a/src/model/Series.ts b/src/model/Series.ts
index fbceb6f..0a6b90c 100644
--- a/src/model/Series.ts
+++ b/src/model/Series.ts
@@ -109,11 +109,15 @@ interface SeriesModel {
class SeriesModel<Opt extends SeriesOption = SeriesOption> extends ComponentModel<Opt> {
- // [Caution]: for compat the previous "class extend"
- // publich and protected fields must be initialized on
- // prototype rather than in constructor. Otherwise the
- // subclass overrided filed will be overwritten by this
- // class. That is, they should not be initialized here.
+ // [Caution]: Becuase this class or desecendants can be used as `XXX.extend(subProto)`,
+ // the class members must not be initialized in constructor or declaration place.
+ // Otherwise there is bad case:
+ // class A {xxx = 1;}
+ // enableClassExtend(A);
+ // class B extends A {}
+ // var C = B.extend({xxx: 5});
+ // var c = new C();
+ // console.log(c.xxx); // expect 5 but always 1.
// @readonly
type: string;
diff --git a/src/view/Chart.ts b/src/view/Chart.ts
index 7c00696..2b5e3d7 100644
--- a/src/view/Chart.ts
+++ b/src/view/Chart.ts
@@ -95,11 +95,15 @@ interface ChartView {
}
class ChartView {
- // [Caution]: for compat the previous "class extend"
- // publich and protected fields must be initialized on
- // prototype rather than in constructor. Otherwise the
- // subclass overrided filed will be overwritten by this
- // class. That is, they should not be initialized here.
+ // [Caution]: Becuase this class or desecendants can be used as `XXX.extend(subProto)`,
+ // the class members must not be initialized in constructor or declaration place.
+ // Otherwise there is bad case:
+ // class A {xxx = 1;}
+ // enableClassExtend(A);
+ // class B extends A {}
+ // var C = B.extend({xxx: 5});
+ // var c = new C();
+ // console.log(c.xxx); // expect 5 but always 1.
// @readonly
type: string;
diff --git a/src/view/Component.ts b/src/view/Component.ts
index 5fbdebd..ca29f47 100644
--- a/src/view/Component.ts
+++ b/src/view/Component.ts
@@ -45,11 +45,15 @@ interface ComponentView {
class ComponentView {
- // [Caution]: for compat the previous "class extend"
- // publich and protected fields must be initialized on
- // prototype rather than in constructor. Otherwise the
- // subclass overrided filed will be overwritten by this
- // class. That is, they should not be initialized here.
+ // [Caution]: Becuase this class or desecendants can be used as `XXX.extend(subProto)`,
+ // the class members must not be initialized in constructor or declaration place.
+ // Otherwise there is bad case:
+ // class A {xxx = 1;}
+ // enableClassExtend(A);
+ // class B extends A {}
+ // var C = B.extend({xxx: 5});
+ // var c = new C();
+ // console.log(c.xxx); // expect 5 but always 1.
readonly group: ViewRootGroup;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org