rename isTagNameSafe to makeTagNameSafe
This commit is contained in:
parent
5476163ec7
commit
8f5d2d34c6
|
@ -48,7 +48,7 @@ function FramedEngine(options) {
|
|||
this.iframeDoc.body.style.padding = "0";
|
||||
this.widget.domNodes.push(this.iframeNode);
|
||||
// Construct the textarea or input node
|
||||
var tag = $tw.utils.isTagNameSafe(this.widget.editTag, "input");
|
||||
var tag = $tw.utils.makeTagNameSafe(this.widget.editTag, "input");
|
||||
// if($tw.config.htmlUnsafeElements.indexOf(tag) !== -1) {
|
||||
// tag = "input";
|
||||
// }
|
||||
|
|
|
@ -22,7 +22,7 @@ function SimpleEngine(options) {
|
|||
this.parentNode = options.parentNode;
|
||||
this.nextSibling = options.nextSibling;
|
||||
// Construct the textarea or input node
|
||||
var tag = $tw.utils.isTagNameSafe(this.widget.editTag,"input");
|
||||
var tag = $tw.utils.makeTagNameSafe(this.widget.editTag,"input");
|
||||
// var tag = this.widget.editTag;
|
||||
// if($tw.config.htmlUnsafeElements.indexOf(tag) !== -1) {
|
||||
// tag = "input";
|
||||
|
|
|
@ -389,10 +389,10 @@ exports.querySelectorAllSafe = function(selector,baseElement) {
|
|||
/*
|
||||
Make sure HTML tag names are valid
|
||||
*/
|
||||
exports.isTagNameSafe = function(tag,defaultTag) {
|
||||
exports.makeTagNameSafe = function(tag,defaultTag) {
|
||||
defaultTag = defaultTag || "SPAN";
|
||||
// This implements standard DOM elements: https://html.spec.whatwg.org/#syntax-tag-name
|
||||
// It does _not_ implement Custom Elements: https://html.spec.whatwg.org/#valid-custom-element-name
|
||||
// This implements a check for standard DOM elements: https://html.spec.whatwg.org/#syntax-tag-name
|
||||
// It does _not_ deal with Custom Elements: https://html.spec.whatwg.org/#valid-custom-element-name
|
||||
var regexp = /[a-zA-Z0-9]/g;
|
||||
if(tag && tag.match(regexp) && $tw.config.htmlUnsafeElements.indexOf(tag) === -1) {
|
||||
return tag;
|
||||
|
|
|
@ -41,7 +41,7 @@ ButtonWidget.prototype.render = function(parent,nextSibling) {
|
|||
// if(this.buttonTag && $tw.config.htmlUnsafeElements.indexOf(this.buttonTag) === -1) {
|
||||
// tag = this.buttonTag;
|
||||
// }
|
||||
tag = $tw.utils.isTagNameSafe(this.buttonTag,tag)
|
||||
tag = $tw.utils.makeTagNameSafe(this.buttonTag,tag)
|
||||
domNode = this.document.createElement(tag);
|
||||
this.domNode = domNode;
|
||||
// Assign classes
|
||||
|
|
|
@ -38,7 +38,7 @@ DraggableWidget.prototype.render = function(parent,nextSibling) {
|
|||
// Execute our logic
|
||||
this.execute();
|
||||
// Sanitise the specified tag
|
||||
tag = $tw.utils.isTagNameSafe(this.draggableTag,"div");
|
||||
tag = $tw.utils.makeTagNameSafe(this.draggableTag,"div");
|
||||
// if($tw.config.htmlUnsafeElements.indexOf(tag) !== -1) {
|
||||
// tag = "div";
|
||||
// }
|
||||
|
|
|
@ -35,7 +35,7 @@ DroppableWidget.prototype.render = function(parent,nextSibling) {
|
|||
// Compute attributes and execute state
|
||||
this.computeAttributes();
|
||||
this.execute();
|
||||
tag = $tw.utils.isTagNameSafe(this.droppableTag,tag);
|
||||
tag = $tw.utils.makeTagNameSafe(this.droppableTag,tag);
|
||||
// if(this.droppableTag && $tw.config.htmlUnsafeElements.indexOf(this.droppableTag) === -1) {
|
||||
// tag = this.droppableTag;
|
||||
// }
|
||||
|
|
|
@ -31,7 +31,7 @@ ElementWidget.prototype.render = function(parent,nextSibling) {
|
|||
this.computeAttributes();
|
||||
// Neuter blacklisted elements
|
||||
this.tag = this.parseTreeNode.tag;
|
||||
this.tag = $tw.utils.isTagNameSafe(this.tag, "safe" + this.tag);
|
||||
this.tag = $tw.utils.makeTagNameSafe(this.tag, "safe" + this.tag);
|
||||
// if($tw.config.htmlUnsafeElements.indexOf(this.tag) !== -1) {
|
||||
// this.tag = "safe-" + this.tag;
|
||||
// }
|
||||
|
|
|
@ -35,7 +35,7 @@ EventWidget.prototype.render = function(parent,nextSibling) {
|
|||
this.execute();
|
||||
// Create element
|
||||
var tag = this.parseTreeNode.isBlock ? "div" : "span";
|
||||
tag = $tw.utils.isTagNameSafe(this.elementTag,tag)
|
||||
tag = $tw.utils.makeTagNameSafe(this.elementTag,tag)
|
||||
// if(this.elementTag && $tw.config.htmlUnsafeElements.indexOf(this.elementTag) === -1) {
|
||||
// tag = this.elementTag;
|
||||
// }
|
||||
|
|
|
@ -34,7 +34,7 @@ KeyboardWidget.prototype.render = function(parent,nextSibling) {
|
|||
this.computeAttributes();
|
||||
this.execute();
|
||||
var tag = this.parseTreeNode.isBlock ? "div" : "span";
|
||||
tag = $tw.utils.isTagNameSafe(this.tag,tag);
|
||||
tag = $tw.utils.makeTagNameSafe(this.tag,tag);
|
||||
// if(this.tag && $tw.config.htmlUnsafeElements.indexOf(this.tag) === -1) {
|
||||
// tag = this.tag;
|
||||
// }
|
||||
|
|
|
@ -61,7 +61,7 @@ LinkWidget.prototype.renderLink = function(parent,nextSibling) {
|
|||
var self = this;
|
||||
// Sanitise the specified tag
|
||||
var tag = this.linkTag;
|
||||
tag = $tw.utils.isTagNameSafe(tag,"a");
|
||||
tag = $tw.utils.makeTagNameSafe(tag,"a");
|
||||
// if($tw.config.htmlUnsafeElements.indexOf(tag) !== -1) {
|
||||
// tag = "a";
|
||||
// }
|
||||
|
|
|
@ -33,7 +33,7 @@ RevealWidget.prototype.render = function(parent,nextSibling) {
|
|||
this.computeAttributes();
|
||||
this.execute();
|
||||
var tag = this.parseTreeNode.isBlock ? "div" : "span";
|
||||
tag = $tw.utils.isTagNameSafe(this.revealTag,tag);
|
||||
tag = $tw.utils.makeTagNameSafe(this.revealTag,tag);
|
||||
// if(this.revealTag && $tw.config.htmlUnsafeElements.indexOf(this.revealTag) === -1) {
|
||||
// tag = this.revealTag;
|
||||
// }
|
||||
|
|
Loading…
Reference in New Issue