Просмотр исходного кода

impl getClassName() to each containers

Yuki Takei 6 лет назад
Родитель
Сommit
0e288253aa

+ 1 - 1
src/client/js/components/UnstatedUtils.jsx

@@ -19,7 +19,7 @@ function generateAutoNamedProps(instances) {
 
 
   instances.forEach((instance) => {
   instances.forEach((instance) => {
     // get class name
     // get class name
-    const className = instance.constructor.name;
+    const className = instance.constructor.getClassName();
     // convert initial charactor to lower case
     // convert initial charactor to lower case
     const propName = `${className.charAt(0).toLowerCase()}${className.slice(1)}`;
     const propName = `${className.charAt(0).toLowerCase()}${className.slice(1)}`;
 
 

+ 8 - 1
src/client/js/services/AppContainer.js

@@ -70,6 +70,13 @@ export default class AppContainer extends Container {
     this.apiRequest = this.apiRequest.bind(this);
     this.apiRequest = this.apiRequest.bind(this);
   }
   }
 
 
+  /**
+   * Workaround for the mangling in production build to break constructor.name
+   */
+  static getClassName() {
+    return 'AppContainer';
+  }
+
   initPlugins() {
   initPlugins() {
     if (this.isPluginEnabled) {
     if (this.isPluginEnabled) {
       const growiPlugin = window.growiPlugin;
       const growiPlugin = window.growiPlugin;
@@ -109,7 +116,7 @@ export default class AppContainer extends Container {
       throw new Error('The specified instance must not be null');
       throw new Error('The specified instance must not be null');
     }
     }
 
 
-    const className = instance.constructor.name;
+    const className = instance.constructor.getClassName();
 
 
     if (this.containerInstances[className] != null) {
     if (this.containerInstances[className] != null) {
       throw new Error('The specified instance couldn\'t register because the same type object has already been registered');
       throw new Error('The specified instance couldn\'t register because the same type object has already been registered');

+ 7 - 0
src/client/js/services/CommentContainer.js

@@ -36,6 +36,13 @@ export default class CommentContainer extends Container {
     this.retrieveComments = this.retrieveComments.bind(this);
     this.retrieveComments = this.retrieveComments.bind(this);
   }
   }
 
 
+  /**
+   * Workaround for the mangling in production build to break constructor.name
+   */
+  static getClassName() {
+    return 'CommentContainer';
+  }
+
   getPageContainer() {
   getPageContainer() {
     return this.appContainer.getContainer('PageContainer');
     return this.appContainer.getContainer('PageContainer');
   }
   }

+ 7 - 0
src/client/js/services/EditorContainer.js

@@ -44,6 +44,13 @@ export default class EditorContainer extends Container {
     this.initEditorOptions('previewOptions', 'previewOptions', defaultPreviewOptions);
     this.initEditorOptions('previewOptions', 'previewOptions', defaultPreviewOptions);
   }
   }
 
 
+  /**
+   * Workaround for the mangling in production build to break constructor.name
+   */
+  static getClassName() {
+    return 'EditorContainer';
+  }
+
   /**
   /**
    * initialize state for page permission
    * initialize state for page permission
    */
    */

+ 7 - 0
src/client/js/services/PageContainer.js

@@ -60,6 +60,13 @@ export default class PageContainer extends Container {
     this.addWebSocketEventHandlers();
     this.addWebSocketEventHandlers();
   }
   }
 
 
+  /**
+   * Workaround for the mangling in production build to break constructor.name
+   */
+  static getClassName() {
+    return 'PageContainer';
+  }
+
   /**
   /**
    * initialize state for markdown data
    * initialize state for markdown data
    */
    */

+ 7 - 0
src/client/js/services/TagContainer.js

@@ -19,6 +19,13 @@ export default class TagContainer extends Container {
     this.init();
     this.init();
   }
   }
 
 
+  /**
+   * Workaround for the mangling in production build to break constructor.name
+   */
+  static getClassName() {
+    return 'TagContainer';
+  }
+
   /**
   /**
    * retrieve tags data
    * retrieve tags data
    * !! This method should be invoked after PageContainer and EditorContainer has been initialized !!
    * !! This method should be invoked after PageContainer and EditorContainer has been initialized !!

+ 7 - 0
src/client/js/services/WebsocketContainer.js

@@ -22,6 +22,13 @@ export default class WebsocketContainer extends Container {
 
 
   }
   }
 
 
+  /**
+   * Workaround for the mangling in production build to break constructor.name
+   */
+  static getClassName() {
+    return 'WebsocketContainer';
+  }
+
   getWebSocket() {
   getWebSocket() {
     return this.socket;
     return this.socket;
   }
   }