From 30650cc047e9198a7d5b4891292836423239d509 Mon Sep 17 00:00:00 2001 From: igoradamenko Date: Sat, 12 May 2018 14:57:25 +0300 Subject: [PATCH] remove useless code from scroll to parent action --- web/app/common/post-message.js | 1 - web/app/components/comment/comment.jsx | 10 +--------- web/app/embed.js | 4 ---- 3 files changed, 1 insertion(+), 14 deletions(-) delete mode 100644 web/app/common/post-message.js diff --git a/web/app/common/post-message.js b/web/app/common/post-message.js deleted file mode 100644 index f8381a2f..00000000 --- a/web/app/common/post-message.js +++ /dev/null @@ -1 +0,0 @@ -export default msg => window.parent.postMessage(JSON.stringify(msg), '*'); diff --git a/web/app/components/comment/comment.jsx b/web/app/components/comment/comment.jsx index 1e426694..9a01da98 100644 --- a/web/app/components/comment/comment.jsx +++ b/web/app/components/comment/comment.jsx @@ -3,7 +3,6 @@ import { h, Component } from 'preact'; import api from 'common/api'; import { API_BASE, BASE_URL, COMMENT_NODE_CLASSNAME_PREFIX } from 'common/constants'; import { url } from 'common/settings'; -import postMessage from 'common/post-message'; import store from 'common/store'; import Input from 'components/input'; @@ -185,18 +184,11 @@ export default class Comment extends Component { scrollToParent(e) { const { data: { pid } } = this.props; - const hash = `#${COMMENT_NODE_CLASSNAME_PREFIX}${pid}`; e.preventDefault(); - // reset old hash - postMessage({ hash: '' }); + const parentCommentNode = document.getElementById(`${COMMENT_NODE_CLASSNAME_PREFIX}${pid}`); - // set new hash - postMessage({ hash }); - - // try to scroll into view - const parentCommentNode = document.querySelector(hash); if (parentCommentNode) { parentCommentNode.scrollIntoView(); } diff --git a/web/app/embed.js b/web/app/embed.js index 0e928754..f69eb2a1 100644 --- a/web/app/embed.js +++ b/web/app/embed.js @@ -61,10 +61,6 @@ function init() { if (data.remarkIframeHeight) { iframe.style.height = `${data.remarkIframeHeight}px`; } - - if (data.hash) { - window.location.hash = data.hash; - } } catch (e) {} }