本文整理汇总了TypeScript中tinymce/core/api/html/SaxParser.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
suite.test('Parse PI', function () {
let counter, parser;
counter = createCounter(writer);
parser = SaxParser(counter, schema);
writer.reset();
parser.parse('<?xml version="1.0" encoding="UTF-8" ?>text1');
LegacyUnit.equal(writer.getContent(), '<?xml version="1.0" encoding="UTF-8" ?>text1', 'Parse PI with attributes.');
LegacyUnit.deepEqual(counter.counts, { pi: 1, text: 1 }, 'Parse PI with attributes counts.');
counter = createCounter(writer);
parser = SaxParser(counter, schema);
writer.reset();
parser.parse('<?xml?>text1');
LegacyUnit.equal(writer.getContent(), '<?xml?>text1', 'Parse PI with no data.');
LegacyUnit.deepEqual(counter.counts, { pi: 1, text: 1 }, 'Parse PI with data counts.');
counter = createCounter(writer);
parser = SaxParser(counter, schema);
writer.reset();
parser.parse('<?xml somevalue/>text1');
LegacyUnit.equal(writer.getContent(), '<?xml somevalue?>text1', 'Parse PI with IE style ending.');
LegacyUnit.deepEqual(counter.counts, { pi: 1, text: 1 }, 'Parse PI with IE style ending counts.');
});
示例2: urls
suite.test('Parse script urls (disallow svg data image uris)', function () {
let counter, parser;
counter = createCounter(writer);
counter.validate = false;
counter.allow_html_data_urls = false;
counter.allow_svg_data_urls = false;
parser = SaxParser(counter, schema);
writer.reset();
parser.parse(
'<a href="data:image/svg+xml;base64,x">1</a>'
);
LegacyUnit.equal(
writer.getContent(),
'<a>1</a>'
);
});
示例3: function
suite.test('parse XSS PI', function () {
let counter, parser;
counter = createCounter(writer);
counter.validate = false;
parser = SaxParser(counter, schema);
writer.reset();
parser.parse(
'<?xml><iframe SRC=javascript:alert('XSS')>?>'
);
LegacyUnit.equal(
writer.getContent(),
'<?xml ><iframe SRC=&#106&#97&#118&#97&#115&#99&#114&#105&#112&' +
'#116&#58&#97&#108&#101&#114&#116&#40&#39&#88&#83&#83&#39&#41>?>'
);
});
示例4: urls
suite.test('Parse script urls (allowed html data uris)', function () {
let counter, parser;
counter = createCounter(writer);
counter.validate = false;
counter.allow_html_data_urls = true;
parser = SaxParser(counter, schema);
writer.reset();
parser.parse(
'<a href="javascript:alert(1)">1</a>' +
'<a href="data:text/html;base64,PHN2Zy9vbmxvYWQ9YWxlcnQoMik+">2</a>'
);
LegacyUnit.equal(
writer.getContent(),
'<a>1</a>' +
'<a href="data:text/html;base64,PHN2Zy9vbmxvYWQ9YWxlcnQoMik+">2</a>'
);
});
示例5: comments
suite.test('Conditional comments (denied)', function () {
let counter, parser;
counter = createCounter(writer);
counter.validate = false;
counter.allow_conditional_comments = false;
parser = SaxParser(counter, schema);
writer.reset();
parser.parse('<!--[if gte IE 4]>alert(1)<![endif]-->');
LegacyUnit.equal(writer.getContent(), '<!-- [if gte IE 4]>alert(1)<![endif]-->');
writer.reset();
parser.parse('<!--[if !IE]>alert(1)<![endif]-->');
LegacyUnit.equal(writer.getContent(), '<!-- [if !IE]>alert(1)<![endif]-->');
writer.reset();
parser.parse('<!--[iF !IE]>alert(1)<![endif]-->');
LegacyUnit.equal(writer.getContent(), '<!-- [iF !IE]>alert(1)<![endif]-->');
});
示例6: function
const updateHtmlSax = function (html, data, updateAll?) {
const writer = Writer();
let sourceCount = 0;
let hasImage;
SaxParser({
validate: false,
allow_conditional_comments: true,
special: 'script,noscript',
comment (text) {
writer.comment(text);
},
cdata (text) {
writer.cdata(text);
},
text (text, raw) {
writer.text(text, raw);
},
start (name, attrs, empty) {
switch (name) {
case 'video':
case 'object':
case 'embed':
case 'img':
case 'iframe':
if (data.height !== undefined && data.width !== undefined) {
setAttributes(attrs, {
width: data.width,
height: data.height
});
}
break;
}
if (updateAll) {
switch (name) {
case 'video':
setAttributes(attrs, {
poster: data.poster,
src: ''
});
if (data.source2) {
setAttributes(attrs, {
src: ''
});
}
break;
case 'iframe':
setAttributes(attrs, {
src: data.source1
});
break;
case 'source':
sourceCount++;
if (sourceCount <= 2) {
setAttributes(attrs, {
src: data['source' + sourceCount],
type: data['source' + sourceCount + 'mime']
});
if (!data['source' + sourceCount]) {
return;
}
}
break;
case 'img':
if (!data.poster) {
return;
}
hasImage = true;
break;
}
}
writer.start(name, attrs, empty);
},
end (name) {
if (name === 'video' && updateAll) {
for (let index = 1; index <= 2; index++) {
if (data['source' + index]) {
const attrs: any = [];
attrs.map = {};
if (sourceCount < index) {
setAttributes(attrs, {
src: data['source' + index],
type: data['source' + index + 'mime']
});
//.........这里部分代码省略.........