Skip to content

OnlyincludeToken

bhsd edited this page Dec 11, 2023 · 13 revisions

Other Languages

简介

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

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

Properties

innerText

type: string
内部wikitext。

// innerText
var {firstChild} = Parser.parse('<onlyinclude>a</onlyinclude>', true);
assert.equal(firstChild, '<onlyinclude>a</onlyinclude>');
assert.strictEqual(firstChild.innerText, 'a');
firstChild.innerText = '[[a]]';
assert.equal(firstChild, '<onlyinclude>[[a]]</onlyinclude>');
assert.strictEqual(firstChild.firstChild.type, 'link');

Methods

cloneNode

returns: this
深拷贝节点。

// cloneNode
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);
Clone this wiki locally