MCPcopy Create free account
hub / github.com/tinymce/tinymce / clone

Method clone

modules/tinymce/src/core/main/ts/api/html/Node.ts:246–272  ·  view source on GitHub ↗

* Does a shallow clones the node into a new node. It will also exclude id attributes since * there should only be one id per document. * * @method clone * @return {tinymce.html.Node} New copy of the original node. * @example * const clonedNode = node.clone();

()

Source from the content-addressed store, hash-verified

244 * const clonedNode = node.clone();
245 */
246 public clone(): AstNode {
247 const self = this;
248 const clone = new AstNode(self.name, self.type);
249 const selfAttrs = self.attributes;
250
251 // Clone element attributes
252 if (selfAttrs) {
253 const cloneAttrs = [] as unknown as Attributes;
254 (cloneAttrs as any).map = {};
255
256 for (let i = 0, l = selfAttrs.length; i < l; i++) {
257 const selfAttr = selfAttrs[i];
258
259 // Clone everything except id
260 if (selfAttr.name !== 'id') {
261 cloneAttrs[cloneAttrs.length] = { name: selfAttr.name, value: selfAttr.value };
262 cloneAttrs.map[selfAttr.name] = selfAttr.value;
263 }
264 }
265
266 clone.attributes = cloneAttrs;
267 }
268
269 clone.value = self.value;
270
271 return clone;
272 }
273
274 /**
275 * Wraps the node in in another node.

Callers 15

cloneRowFunction · 0.80
rowFillFunction · 0.80
NodeTest.tsFile · 0.80
ClientRectTest.tsFile · 0.80
renderFunction · 0.80
toArrayWithNodeFunction · 0.80
positionsUntilFunction · 0.80
getBrClientRectFunction · 0.80
getBoundingClientRectFunction · 0.80
getCornersFunction · 0.80
cleanInvalidNodesFunction · 0.80
createEntryFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected