本文整理汇总了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');
});
示例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);
});
示例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>');
});
示例4:
const sAddTestDiv = Step.sync(function () {
const div = document.createElement('div');
div.innerHTML = 'xxx';
div.contentEditable = 'true';
div.id = testDivId;
document.body.appendChild(div);
});
示例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();
}
}
};
示例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;
};
示例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);
}
});
示例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'
}
});
};