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


TypeScript document.createElement方法代码示例

本文整理汇总了TypeScript中@ephox/dom-globals.document.createElement方法的典型用法代码示例。如果您正苦于以下问题:TypeScript document.createElement方法的具体用法?TypeScript document.createElement怎么用?TypeScript document.createElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@ephox/dom-globals.document的用法示例。


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

示例1:

  suite.test('should not throw error when passed in element without parent', () => {
    const rootDiv = document.createElement('div');
    const element = document.createElement('p');

    const actual = FontInfo.getFontSize(rootDiv, element);

    LegacyUnit.equal('string', typeof actual, 'should return always string');
  });
开发者ID:danielpunkass,项目名称:tinymce,代码行数:8,代码来源:FontInfoTest.ts

示例2: function

  suite.test('hasPropValue', function () {
    const hasTabIndex3 = NodeType.hasPropValue('tabIndex', 3);

    LegacyUnit.strictEqual(hasTabIndex3(null), false);
    LegacyUnit.strictEqual(hasTabIndex3($('<div tabIndex="3"></div>')[0]), true);
    LegacyUnit.strictEqual(hasTabIndex3(document.createElement('div')), false);
    LegacyUnit.strictEqual(hasTabIndex3(document.createElement('b')), false);
  });
开发者ID:danielpunkass,项目名称:tinymce,代码行数:8,代码来源:NodeTypeTest.ts

示例3: function

  suite.test('Custom elements', function () {
    const ser = Serializer({
      custom_elements: 'custom1,~custom2',
      valid_elements: 'custom1,custom2'
    });

    document.createElement('custom1');
    document.createElement('custom2');

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

示例4:

 const sAddTestDiv = Step.sync(function () {
   const div = document.createElement('div');
   div.innerHTML = 'xxx';
   div.contentEditable = 'true';
   div.id = testDivId;
   document.body.appendChild(div);
 });
开发者ID:tinymce,项目名称:tinymce,代码行数:7,代码来源:GetSelectionContentTest.ts

示例5: function

const open = function (url) {
  // Chrome and Webkit has implemented noopener and works correctly with/without popup blocker
  // Firefox has it implemented noopener but when the popup blocker is activated it doesn't work
  // Edge has only implemented noreferrer and it seems to remove opener as well
  // Older IE versions pre IE 11 falls back to a window.open approach
  if (!Env.ie || Env.ie > 10) {
    const link = document.createElement('a');
    link.target = '_blank';
    link.href = url;
    link.rel = 'noreferrer noopener';

    const evt = document.createEvent('MouseEvents');
    evt.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);

    appendClickRemove(link, evt);
  } else {
    const win: any = window.open('', '_blank');
    if (win) {
      win.opener = null;
      const doc = win.document;
      doc.open();
      doc.write('<meta http-equiv="refresh" content="0; url=' + DOMUtils.DOM.encode(url) + '">');
      doc.close();
    }
  }
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:26,代码来源:OpenUrl.ts

示例6: function

const getImageSize = function (url, callback) {
  const img = document.createElement('img');

  function done(dimensions) {
    if (img.parentNode) {
      img.parentNode.removeChild(img);
    }

    callback(dimensions);
  }

  img.onload = function () {
    const width = parseIntAndGetMax(img.width, img.clientWidth);
    const height = parseIntAndGetMax(img.height, img.clientHeight);
    const dimensions = {width, height};
    done(Result.value(dimensions));
  };

  img.onerror = function () {
    done(Result.error(undefined));
  };

  const style = img.style;
  style.visibility = 'hidden';
  style.position = 'fixed';
  style.bottom = style.left = '0px';
  style.width = style.height = 'auto';

  document.body.appendChild(img);
  img.src = url;
};
开发者ID:tinymce,项目名称:tinymce,代码行数:31,代码来源:Utils.ts

示例7: function

    self.state.on('change:icon', function (e) {
      let icon = e.value;
      const prefix = self.classPrefix;

      if (typeof icon === 'undefined') {
        return self.settings.icon;
      }

      self.settings.icon = icon;
      icon = icon ? prefix + 'ico ' + prefix + 'i-' + self.settings.icon : '';

      const btnElm = self.getEl().firstChild;
      let iconElm = btnElm.getElementsByTagName('i')[0];

      if (icon) {
        if (!iconElm || iconElm !== btnElm.firstChild) {
          iconElm = document.createElement('i');
          btnElm.insertBefore(iconElm, btnElm.firstChild);
        }

        iconElm.className = icon;
      } else if (iconElm) {
        btnElm.removeChild(iconElm);
      }
    });
开发者ID:danielpunkass,项目名称:tinymce,代码行数:25,代码来源:Checkbox.ts

示例8: function

  const setup = function (success, failure) {
    const div = document.createElement('div');

    div.innerHTML = (
      '<div id="lists">' +
      '<ul><li>before</li></ul>' +
      '<ul id="inline"><li>x</li></ul>' +
      '<ul><li>after</li></ul>' +
      '</div>'
    );

    document.body.appendChild(div);

    EditorManager.init({
      selector: '#inline',
      inline: true,
      add_unload_trigger: false,
      skin: false,
      plugins: 'lists',
      disable_nodechange: true,
      init_instance_callback (editor) {
        Pipeline.async({}, Log.steps('TBA', 'Lists: Backspace delete inline tests', suite.toSteps(editor)), function () {
          teardown(editor, div);
          success();
        }, failure);
      },
      valid_styles: {
        '*': 'color,font-size,font-family,background-color,font-weight,font-style,text-decoration,float,' +
        'margin,margin-top,margin-right,margin-bottom,margin-left,display,position,top,left,list-style-type'
      }
    });
  };
开发者ID:tinymce,项目名称:tinymce,代码行数:32,代码来源:BackspaceDeleteInlineTest.ts


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