From b35d6bff27923ac1b3fd22787bfa318dd2155150 Mon Sep 17 00:00:00 2001 From: ache Date: Sat, 19 May 2018 03:38:46 +0200 Subject: Fix composition function --- index.js | 11 ++++++++--- package.json | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 5dea736..ace52e5 100644 --- a/index.js +++ b/index.js @@ -109,8 +109,13 @@ function filterAttributes(prop, config, type) { }); const isDangerous = p => DOMEventHandler.indexOf(p) >= 0; + const isSpecific = p => 'type' in specific && specific[type].indexOf(p) >= 0; + const isGlobal = p => htmlElemAttr['*'].indexOf(p) >= 0; + let inScope = _ => false; + const orFunc = (fun, fun2) => x => fun(x) || fun2(x); + switch (scope) { case 'none': // Plugin is disabled break; @@ -126,13 +131,13 @@ function filterAttributes(prop, config, type) { inScope = p => extend[type].indexOf(p) >= 0; // Or if it in the specific scope, fallthrough case 'specific': - inScope = p => (inScope(p) || specific[type].indexOf(p) >= 0); + inScope = orFunc(inScope, isSpecific); // Or if it in the global scope fallthrough case 'global': default: - inScope = p => (inScope(p) || htmlElemAttr['*'].indexOf(p) >= 0); + inScope = orFunc(inScope, isGlobal); if (allowDangerousDOMEventHandlers) { // If allowed add dangerous attributes to global scope - inScope = p => (inScope(p) || isDangerous(p)); + inScope = orFunc(inScope, isDangerous); } } diff --git a/package.json b/package.json index 9e5b437..543dfa9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "remark-attr", - "version": "0.6.0", + "version": "0.6.1", "description": "Add support of custom attributes to Markdown syntax.", "main": "index.js", "scripts": { -- cgit v1.2.3