Lock down element type creation
This commit is contained in:
parent
1935f4b045
commit
40139e1c02
5
packages/projector/src/constants.js
Normal file
5
packages/projector/src/constants.js
Normal file
@ -0,0 +1,5 @@
|
||||
export const ALLOWED_SETTABLE_PROPERTIES = 'style lang dataset dir tabIndex textContent title scrollTop scrollLeft className width height'.split(
|
||||
' '
|
||||
);
|
||||
export const DISALLOWED_ELEMENTS = 'script embed object style'.split(' ');
|
||||
export const OVERRIDING_EVENTS = ['contextmenu', 'dragover', 'drop'];
|
||||
@ -1,11 +1,12 @@
|
||||
import { isFunction } from 'trimkit';
|
||||
|
||||
import { supportsPassive } from './utils.js';
|
||||
import {
|
||||
ALLOWED_SETTABLE_PROPERTIES,
|
||||
DISALLOWED_ELEMENTS,
|
||||
OVERRIDING_EVENTS
|
||||
} from './constants.js';
|
||||
|
||||
const ALLOWED_SETTABLE_PROPERTIES = 'style lang dataset dir tabIndex title scrollTop scrollLeft className width height'.split(
|
||||
' '
|
||||
);
|
||||
const OVERRIDING_EVENTS = ['contextmenu', 'dragover', 'drop'];
|
||||
function getEventList(element) {
|
||||
const evtString = element.getAttribute('evl');
|
||||
return evtString ? evtString.split(';') : [];
|
||||
@ -88,7 +89,11 @@ export function Projector(domRoot) {
|
||||
if (type === 3) {
|
||||
element = document.createTextNode(props.textContent);
|
||||
} else if (type === 1) {
|
||||
element = document.createElement(name);
|
||||
if (DISALLOWED_ELEMENTS.includes(name)) {
|
||||
element = document.createElement('div');
|
||||
} else {
|
||||
element = document.createElement(name);
|
||||
}
|
||||
}
|
||||
elementMap.set((element._id = id), element);
|
||||
setAttributes(element, props);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user