aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorache <ache@ache.one>2018-05-19 03:38:46 +0200
committerache <ache@ache.one>2018-05-19 03:38:46 +0200
commitb35d6bff27923ac1b3fd22787bfa318dd2155150 (patch)
tree086644804ff3428bb521887fbaeebfcef4d75c7c
parentNew version (diff)
Fix composition function
-rw-r--r--index.js11
-rw-r--r--package.json2
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": {