当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript SaxParser.default函数代码示例

本文整理汇总了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.');
  });
开发者ID:danielpunkass,项目名称:tinymce,代码行数:24,代码来源:SaxParserTest.ts

示例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>'
    );
  });
开发者ID:danielpunkass,项目名称:tinymce,代码行数:17,代码来源:SaxParserTest.ts

示例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=&#106&#97&#118&#97&#115&#99&#114&#105&#112&#116&#58&#97&#108&#101&#114&#116&#40&#39&#88&#83&#83&#39&#41>?>'
    );

    LegacyUnit.equal(
      writer.getContent(),
      '<?xml &gt;&lt;iframe SRC=&amp;#106&amp;#97&amp;#118&amp;#97&amp;#115&amp;#99&amp;#114&amp;#105&amp;#112&amp;' +
      '#116&amp;#58&amp;#97&amp;#108&amp;#101&amp;#114&amp;#116&amp;#40&amp;#39&amp;#88&amp;#83&amp;#83&amp;#39&amp;#41&gt;?>'
    );
  });
开发者ID:abstask,项目名称:tinymce,代码行数:18,代码来源:SaxParserTest.ts

示例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>'
    );
  });
开发者ID:abstask,项目名称:tinymce,代码行数:18,代码来源:SaxParserTest.ts

示例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]-->');
  });
开发者ID:abstask,项目名称:tinymce,代码行数:20,代码来源:SaxParserTest.ts

示例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']
              });

//.........这里部分代码省略.........
开发者ID:abstask,项目名称:tinymce,代码行数:101,代码来源:UpdateHtml.ts


注:本文中的tinymce/core/api/html/SaxParser.default函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。