Whether a value is a component, from this copy of docx or from another, such as the copy a plugin or another
library that builds on docx was bundled with. A component from another copy isn't an instance of this copy's
classes, so it is known by the method that writes it.
The method is checked, rather than a marker such as a Symbol.for brand, because copies of docx that predate any
marker wouldn't carry it, while every copy's components have prepForXml. Overriding Symbol.hasInstance on the
base class isn't an option either: subclasses inherit it, so instanceof Paragraph would match any component.
What it doesn't take for a component stays safe: an object to write as XML, such as { "w:b": {} }, has no
methods, and neither has a component copied without its class (with Object.assign or spread), which has lost the
method that would write it.
Whether a value is a component, from this copy of docx or from another, such as the copy a plugin or another library that builds on docx was bundled with. A component from another copy isn't an instance of this copy's classes, so it is known by the method that writes it.
The method is checked, rather than a marker such as a
Symbol.forbrand, because copies of docx that predate any marker wouldn't carry it, while every copy's components haveprepForXml. OverridingSymbol.hasInstanceon the base class isn't an option either: subclasses inherit it, soinstanceof Paragraphwould match any component.What it doesn't take for a component stays safe: an object to write as XML, such as
{ "w:b": {} }, has no methods, and neither has a component copied without its class (withObject.assignor spread), which has lost the method that would write it.