You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by wa...@apache.org on 2022/08/04 01:15:40 UTC

[echarts-examples] branch gh-pages updated: fix(editor): clear the opener after the example code is loaded

This is an automated email from the ASF dual-hosted git repository.

wangzx pushed a commit to branch gh-pages
in repository https://gitbox.apache.org/repos/asf/echarts-examples.git


The following commit(s) were added to refs/heads/gh-pages by this push:
     new cc3eba04 fix(editor): clear the opener after the example code is loaded
cc3eba04 is described below

commit cc3eba049d83a764ba7fc79e06a87c6abf1747b0
Author: plainheart <yh...@all-my-life.cn>
AuthorDate: Thu Aug 4 09:14:31 2022 +0800

    fix(editor): clear the opener after the example code is loaded
---
 src/common/helper.js | 2 +-
 src/common/store.js  | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/common/helper.js b/src/common/helper.js
index 02fdae61..7d43fb86 100644
--- a/src/common/helper.js
+++ b/src/common/helper.js
@@ -113,7 +113,7 @@ export function decompressStr(str) {
   );
 }
 
-export function isOpenedByEChartsWebsite() {
+export function isTrustedOpener() {
   try {
     return (
       window.opener && window.opener.origin === 'https://echarts.apache.org'
diff --git a/src/common/store.js b/src/common/store.js
index b006cc79..d9ce3c64 100644
--- a/src/common/store.js
+++ b/src/common/store.js
@@ -2,7 +2,7 @@
 import { URL_PARAMS } from '../common/config';
 import CHART_LIST from '../data/chart-list-data';
 import CHART_LIST_GL from '../data/chart-list-data-gl';
-import { compressStr, decompressStr, isOpenedByEChartsWebsite } from './helper';
+import { compressStr, decompressStr, isTrustedOpener } from './helper';
 import { customAlphabet } from 'nanoid';
 
 const nanoid = customAlphabet('1234567890abcdefghijklmnopqrstuvwxyz', 10);
@@ -115,7 +115,9 @@ export function loadExampleCode() {
         // PENDING fallback to `c` if the decompressed code is not available?
         const code = decompressStr(URL_PARAMS.code);
         // not considered as shared code if it's opened by echarts website like echarts-doc
-        store.isSharedCode = !isOpenedByEChartsWebsite() && !!code;
+        store.isSharedCode = !isTrustedOpener() && !!code;
+        // clear the opener
+        window.opener = null;
         return code
           ? resolve(code)
           : reject('code was decompressed but got nothing');


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org