diff options
author | ache <ache@ache.one> | 2018-05-19 03:38:46 +0200 |
---|---|---|
committer | ache <ache@ache.one> | 2018-05-19 03:38:46 +0200 |
commit | b35d6bff27923ac1b3fd22787bfa318dd2155150 (patch) | |
tree | 086644804ff3428bb521887fbaeebfcef4d75c7c /index.js | |
parent | New version (diff) |
Fix composition function
Diffstat (limited to 'index.js')
-rw-r--r-- | index.js | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -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); } } |