OnlyincludeToken - bhsd-harry/wikiparser-node GitHub Wiki

Other Languages

简介

被<onlyinclude>和</onlyinclude>包裹的内容。仅在嵌入时(即 Parser.parse(text, true))生效。

以下所有属性和方法在 Mini 和 Browser 版本中均不可用。

Properties

innerText

type: string
内部wikitext。

// innerText (main)
var {firstChild} = Parser.parse('<onlyinclude>a</onlyinclude>', true);
assert.equal(firstChild, '<onlyinclude>a</onlyinclude>');
assert.strictEqual(firstChild.innerText, 'a');
firstChild.innerText = '[a](/bhsd-harry/wikiparser-node/wiki/a)';
assert.equal(firstChild, '<onlyinclude>[a](/bhsd-harry/wikiparser-node/wiki/a)</onlyinclude>');
assert.strictEqual(firstChild.firstChild.type, 'link');

Methods

cloneNode

returns: this
深拷贝节点。

// cloneNode (main)
var {firstChild} = Parser.parse('<onlyinclude>a</onlyinclude>', true),
	cloned = firstChild.cloneNode();
assert.equal(firstChild, '<onlyinclude>a</onlyinclude>');
assert.equal(cloned, '<onlyinclude>a</onlyinclude>');
assert.deepStrictEqual(cloned, firstChild);