From 0d5462829a604e75fd44f9d2a4a176ca07f2d8d3 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 18 Feb 2017 17:29:27 +0900 Subject: [PATCH] :v: --- src/web/app/desktop/scripts/user-preview.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/web/app/desktop/scripts/user-preview.js b/src/web/app/desktop/scripts/user-preview.js index 8816eb41b..8351f0e75 100644 --- a/src/web/app/desktop/scripts/user-preview.js +++ b/src/web/app/desktop/scripts/user-preview.js @@ -2,16 +2,12 @@ const riot = require('riot'); riot.mixin('user-preview', { init: () => { - this.on('mount', () => { - scan.call(this); - }); - this.on('updated', () => { - scan.call(this); - }); - function scan(){ + const scan = () => { this.root.querySelectorAll('[data-user-preview]:not([data-user-preview-attached])') .forEach(attach.bind(this)); - } + }; + this.on('mount', scan); + this.on('updated', scan); } }); @@ -59,12 +55,12 @@ function attach(el) { tag = riot.mount(document.body.appendChild(preview), { user: user })[0]; - } + }; const close = () => { if (tag) { tag.close(); tag = null; } - } + }; }