Skip to content
This repository has been archived by the owner on Oct 7, 2022. It is now read-only.

Commit

Permalink
BugFix of LsxPostRenderInterceptor
Browse files Browse the repository at this point in the history
  • Loading branch information
yuki-takei committed Aug 18, 2019
1 parent 7b01be1 commit 0963b23
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
12 changes: 5 additions & 7 deletions src/client/js/util/Interceptor/LsxPostRenderInterceptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ReactDOM from 'react-dom';

import { BasicInterceptor } from 'growi-commons';

import LsxContext from 'growi-plugin-lsx/src/client/js/util/LsxContext';
import LsxContext from '../LsxContext';
import Lsx from '../../components/Lsx';

/**
Expand Down Expand Up @@ -34,15 +34,13 @@ export default class LsxPostRenderInterceptor extends BasicInterceptor {
process(contextName, ...args) {
const context = Object.assign(args[0]); // clone

// forEach keys of tagContextMap
Object.keys(context.tagContextMap).forEach((domId) => {
// forEach keys of lsxContextMap
Object.keys(context.lsxContextMap).forEach((domId) => {
const elem = document.getElementById(domId);

if (elem) {
// get TagContext instance from context
const tagContext = context.tagContextMap[domId] || {};
// create LsxContext instance
const lsxContext = new LsxContext(tagContext);
// instanciate LsxContext from context
const lsxContext = new LsxContext(context.lsxContextMap[domId] || {});
lsxContext.fromPagePath = context.currentPagePath;

this.renderReactDOM(lsxContext, elem);
Expand Down
11 changes: 8 additions & 3 deletions src/client/js/util/Interceptor/LsxPreRenderInterceptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ export default class LsxPreRenderInterceptor extends BasicInterceptor {
);
}

/**
* @inheritdoc
*/
isProcessableParallel() {
return false;
}

/**
* @inheritdoc
*/
Expand All @@ -27,13 +34,11 @@ export default class LsxPreRenderInterceptor extends BasicInterceptor {
const parsedHTML = context.parsedHTML;
this.initializeCache(contextName);

context.lsxContextMap = {};

const tagPattern = /ls|lsx/;
const result = customTagUtils.findTagAndReplace(tagPattern, parsedHTML);

context.parsedHTML = result.html;
context.tagContextMap = result.tagContextMap;
context.lsxContextMap = result.tagContextMap;

// resolve
return Promise.resolve(context);
Expand Down

0 comments on commit 0963b23

Please sign in to comment.