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


TypeScript Serializer.default函数代码示例

本文整理汇总了TypeScript中tinymce/core/api/dom/Serializer.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了default函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: function

  suite.test('Schema rules', function () {
    let ser = Serializer({ fix_list_elements : true });

    ser.setRules('@[id|title|class|style],div,img[src|alt|-style|border],span,hr');
    DOM.setHTML('test', '<img title="test" src="tinymce/ui/img/raster.gif" data-mce-src="tinymce/ui/img/raster.gif" alt="test" ' +
      'border="0" style="border: 1px solid red" class="test" /><span id="test2">test</span><hr />');
    LegacyUnit.equal(
      ser.serialize(DOM.get('test'), { getInner: true }),
      '<img title="test" class="test" src="tinymce/ui/img/raster.gif" ' +
      'alt="test" border="0" /><span id="test2">test</span><hr />', 'Global rule'
    );

    ser.setRules('*a[*],em/i[*],strong/b[*i*]');
    DOM.setHTML('test', '<a href="test" data-mce-href="test">test</a><strong title="test" class="test">test2</strong><em title="test">test3</em>');
    LegacyUnit.equal(ser.serialize(DOM.get('test')), '<a href="test">test</a><strong title="test">test2</strong><em title="test">' +
      'test3</em>', 'Wildcard rules');

    ser.setRules('br,hr,input[type|name|value],div[id],span[id],strong/b,a,em/i,a[!href|!name],img[src|border=0|title={$uid}]');
    DOM.setHTML('test', '<br /><hr /><input type="text" name="test" value="val" class="no" />' +
      '<span id="test2" class="no"><b class="no">abc</b><em class="no">123</em></span>123<a href="file.html" ' +
      'data-mce-href="file.html">link</a><a name="anchor"></a><a>no</a><img src="tinymce/ui/img/raster.gif" ' +
      'data-mce-src="tinymce/ui/img/raster.gif" />');
    LegacyUnit.equal(ser.serialize(DOM.get('test')), '<div id="test"><br /><hr /><input type="text" name="test" value="val" />' +
      '<span id="test2"><strong>abc</strong><em>123</em></span>123<a href="file.html">link</a>' +
      '<a name="anchor"></a>no<img src="tinymce/ui/img/raster.gif" border="0" title="mce_0" /></div>', 'Output name and attribute rules');

    ser.setRules('img[src|border=0|alt=]');
    DOM.setHTML('test', '<img src="tinymce/ui/img/raster.gif" data-mce-src="tinymce/ui/img/raster.gif" border="0" alt="" />');
    LegacyUnit.equal(ser.serialize(DOM.get('test')), '<img src="tinymce/ui/img/raster.gif" border="0" alt="" />', 'Default attribute with empty value');

    ser.setRules('img[src|border=0|alt=],div[style|id],*[*]');
    DOM.setHTML('test', '<img src="tinymce/ui/img/raster.gif" data-mce-src="tinymce/ui/img/raster.gif" /><hr />');
    LegacyUnit.equal(
      ser.serialize(DOM.get('test'), { getInner: true }),
      '<img src="tinymce/ui/img/raster.gif" border="0" alt="" /><hr />'
    );

    ser = Serializer({
      valid_elements : 'img[src|border=0|alt=]',
      extended_valid_elements : 'div[id],img[src|alt=]'
    });
    DOM.setHTML('test', '<img src="tinymce/ui/img/raster.gif" data-mce-src="tinymce/ui/img/raster.gif" alt="" />');
    LegacyUnit.equal(
      ser.serialize(DOM.get('test')),
      '<div id="test"><img src="tinymce/ui/img/raster.gif" alt="" /></div>'
    );

    ser = Serializer({ invalid_elements : 'hr,br' });
    DOM.setHTML('test', '<img src="tinymce/ui/img/raster.gif" data-mce-src="tinymce/ui/img/raster.gif" /><hr /><br />');
    LegacyUnit.equal(
      ser.serialize(DOM.get('test'), { getInner: true }),
      '<img src="tinymce/ui/img/raster.gif" />'
    );
  });
开发者ID:tinymce,项目名称:tinymce,代码行数:54,代码来源:SerializerTest.ts

示例2: elements

  suite.test('Form elements (select)', function () {
    const ser = Serializer({ fix_list_elements : true });

    ser.setRules('form[method],label[for],input[type|name|value|checked|disabled|readonly|length|maxlength],select[multiple],option[value|selected]');

    DOM.setHTML('test', '<select><option value="1">test1</option><option value="2" selected>test2</option></select>');
    LegacyUnit.equal(ser.serialize(DOM.get('test')), '<select><option value="1">test1</option><option value="2" selected="selected">test2</option></select>');

    DOM.setHTML('test', '<select><option value="1">test1</option><option selected="1" value="2">test2</option></select>');
    LegacyUnit.equal(ser.serialize(DOM.get('test')), '<select><option value="1">test1</option><option value="2" selected="selected">test2</option></select>');

    DOM.setHTML('test', '<select><option value="1">test1</option><option value="2" selected="true">test2</option></select>');
    LegacyUnit.equal(ser.serialize(DOM.get('test')), '<select><option value="1">test1</option><option value="2" selected="selected">test2</option></select>');

    DOM.setHTML('test', '<select multiple></select>');
    LegacyUnit.equal(ser.serialize(DOM.get('test')), '<select multiple="multiple"></select>');

    DOM.setHTML('test', '<select multiple="multiple"></select>');
    LegacyUnit.equal(ser.serialize(DOM.get('test')), '<select multiple="multiple"></select>');

    DOM.setHTML('test', '<select multiple="1"></select>');
    LegacyUnit.equal(ser.serialize(DOM.get('test')), '<select multiple="multiple"></select>');

    DOM.setHTML('test', '<select></select>');
    LegacyUnit.equal(ser.serialize(DOM.get('test')), '<select></select>');
  });
开发者ID:tinymce,项目名称:tinymce,代码行数:26,代码来源:SerializerTest.ts


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