Skip to content

Commit

Permalink
Merge pull request #195 from tbranyen/remove-blacklist-whitelist
Browse files Browse the repository at this point in the history
Remove blacklist whitelist
  • Loading branch information
tbranyen committed Aug 10, 2020
2 parents 68c54ea + 0c5343d commit 16e6943
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions packages/diffhtml/lib/node/patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { PATCH_TYPE, ValidNode, VTree } from '../util/types';
import { NodeCache, TransitionCache } from '../util/caches';

const { keys } = Object;
const blacklist = new Set();
const whitelist = new Set();
const blocklist = new Set();
const allowlist = new Set();

/**
* Directly set this attributes, in addition to setting as properties.
Expand Down Expand Up @@ -38,21 +38,21 @@ const setAttribute = (vTree, domNode, name, value) => {
const lowerName = isEvent ? name.toLowerCase() : name;

// Runtime checking if the property can be set.
const blacklistName = vTree.nodeName + '-' + lowerName;
const blocklistName = vTree.nodeName + '-' + lowerName;

/** @type {HTMLElement} */
const htmlElement = (domNode);

// Since this is a property value it gets set directly on the node.
if (whitelist.has(blacklistName)) {
if (allowlist.has(blocklistName)) {
/** @type {any} */ (domNode)[lowerName] = value;
}
else if (!blacklist.has(blacklistName)) {
else if (!blocklist.has(blocklistName)) {
try {
/** @type {any} */ (domNode)[lowerName] = value;
whitelist.add(blacklistName);
allowlist.add(blocklistName);
} catch (unhandledException) {
blacklist.add(blacklistName);
blocklist.add(blocklistName);
}
}

Expand Down Expand Up @@ -89,9 +89,9 @@ const removeAttribute = (domNode, name) => {
/** @type {HTMLElement} */ (domNode).removeAttribute(name);

// Runtime checking if the property can be set.
const blacklistName = /** @type {HTMLElement} */ (domNode).nodeName + '-' + name;
const blocklistName = /** @type {HTMLElement} */ (domNode).nodeName + '-' + name;

if (whitelist.has(blacklistName)) {
if (allowlist.has(blocklistName)) {
const anyNode = /** @type {any} */ (domNode);

if (isEvent) {
Expand All @@ -104,7 +104,7 @@ const removeAttribute = (domNode, name) => {
/** @type {any} */ (domNode)[name] = false;
}
}
else if (!blacklist.has(blacklistName)) {
else if (!blocklist.has(blocklistName)) {
try {
const anyNode = /** @type {any} */ (domNode);
if (isEvent) {
Expand All @@ -117,9 +117,9 @@ const removeAttribute = (domNode, name) => {
/** @type {any} */ (domNode)[name] = false;
}

whitelist.add(blacklistName);
allowlist.add(blocklistName);
} catch (unhandledException) {
blacklist.add(blacklistName);
blocklist.add(blocklistName);
}
}
};
Expand Down

0 comments on commit 16e6943

Please sign in to comment.