From 2581078ccf66ac103f1e3d81adb10e77fb21bbec Mon Sep 17 00:00:00 2001 From: "Ilya Ig. Petrov" Date: Sun, 21 May 2017 15:04:28 -0700 Subject: [PATCH] Replace data-attrs to arguments in data flow --- .../pages/options/src/components/InfoLi.js | 2 -- .../pages/options/src/components/Main.js | 11 +++++------ .../pages/options/src/components/ModList.js | 8 +++++++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/InfoLi.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/InfoLi.js index 597fd1e..17bc2db 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/InfoLi.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/InfoLi.js @@ -123,8 +123,6 @@ export default function getInfoLi() { id={iddy} onClick={props.onClick} disabled={props.disabled} - data-category={props['data-category']} - data-index={props['data-index']} />
diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/Main.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/Main.js index b707ade..7960b91 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/Main.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/Main.js @@ -62,18 +62,16 @@ export default function getMain(theState) { } - handleModCheck(that, event) { + handleModCheck(that, {targetConf, targetIndex}) { - const checkbox = event.target; - const [tCat, tIndex] = [checkbox.dataset.category, parseInt(checkbox.dataset.index)]; const oldCats = that.state.catToOrderedMods; const newCats = Object.keys(that.state.catToOrderedMods).reduce((acc, cat) => { - if (cat !== tCat) { + if (cat !== targetConf.category) { acc[cat] = oldCats[cat]; } else { acc[cat] = oldCats[cat].map( - (conf, index) => tIndex === index + (conf, index) => targetIndex === index ? Object.assign({}, conf, {value: !conf.value}) : conf ); @@ -103,7 +101,8 @@ export default function getMain(theState) { const modsHandlers = { onChange: linkEvent(this, this.handleModChange), - onClick: linkEvent(this, this.handleModCheck), + //onClick: linkEvent(this, this.handleModCheck), + onClick: (...args) => this.handleModCheck(this, ...args), }; return createElement(TabPanel, { diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ModList.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ModList.js index 972833f..3716be0 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ModList.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/pages/options/src/components/ModList.js @@ -11,7 +11,13 @@ export default function getModList(theState) {
    { props.orderedConfigs.map((conf, index) => ( - + props.onClick({targetConf: conf, targetIndex: index})} + > {props.childrenOfMod && props.childrenOfMod[conf.key]} ) )