: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
if (!this[_hasChildren] || !this[$onChildCheck](child)) {
const name = child[$nodeName];
if (node instanceof XFAObjectArray) {
this[$appendChild](child);
this[$removeChild](node);
this[$appendChild](child);
id = ` (id: ${this.id})`;
id = ` (name: ${this.name} ${this.h.value})`;
warn(`XFA - node "${this[$nodeName]}"${id} has already enough "${name}"!`);
return this.hasOwnProperty(child[$nodeName]) && child[$namespaceId] === this[$namespaceId];
this[$getTemplateRoot]()[$extra].paraStack.pop();
this[$getTemplateRoot]()[$extra].paraStack.push(this.para);
if (this.id && this[$namespaceId] === NamespaceIds.template.id) {
return this[$globalData].template;
this[_children].push(child);
if (!child[$globalData] && this[$globalData]) {
child[$globalData] = this[$globalData];
const i = this[_children].indexOf(child);
this[_children].splice(i, 1);
return this.hasOwnProperty("value");
delete this[_hasChildren];
builder.clean(this[$cleanup]);
return this[_children].indexOf(child);
this[_children].splice(i, 0, child);
if (!child[$globalData] && this[$globalData]) {
child[$globalData] = this[$globalData];
if (this[_children].length === 0) {
return this[_children].map(c => c[$text]()).join("");
get [_attributeNames]() {
const proto = Object.getPrototypeOf(this);
if (!proto._attributes) {
const attributes = proto._attributes = new Set();
for (const name of Object.getOwnPropertyNames(this)) {
if (this[name] === null || this[name] instanceof XFAObject || this[name] instanceof XFAObjectArray) {
return shadow(this, _attributeNames, proto._attributes);
[$isDescendent](parent) {
node = node[$getParent]();
return this[$getParent]();
[$getChildren](name = null) {
const dumped = Object.create(null);
dumped.$content = this[$content];
for (const name of Object.getOwnPropertyNames(this)) {
const value = this[name];
if (value instanceof XFAObject) {
dumped[name] = value[$dump]();
} else if (value instanceof XFAObjectArray) {
dumped[name] = value.dump();
*[$getContainedChildren]() {
for (const node of this[$getChildren]()) {
*[_filteredChildrenGenerator](filter, include) {
for (const node of this[$getContainedChildren]()) {
if (!filter || include === filter.has(node[$nodeName])) {
const availableSpace = this[$getAvailableSpace]();
const res = node[$toHTML](availableSpace);
this[$extra].failingNode = node;
this[$extra].children.push(html);
[$getAvailableSpace]() {}
if (!this[$extra].generator) {
this[$extra].generator = this[_filteredChildrenGenerator](filter, include);
const availableSpace = this[$getAvailableSpace]();
const res = this[$extra].failingNode[$toHTML](availableSpace);
this[$addHTML](res.html, res.bbox);
delete this[$extra].failingNode;
const gen = this[$extra].generator.next();
this[$addHTML](res.html, res.bbox);
this[$extra].generator = null;
[$setSetAttributes](attributes) {
this[_setAttributes] = new Set(Object.keys(attributes));
[_getUnsetAttributes](protoAttributes) {
const allAttr = this[_attributeNames];
const setAttr = this[_setAttributes];
return [...protoAttributes].filter(x => allAttr.has(x) && !setAttr.has(x));
[$resolvePrototypes](ids, ancestors = new Set()) {
for (const child of this[_children]) {
child[_resolvePrototypesHelper](ids, ancestors);
[_resolvePrototypesHelper](ids, ancestors) {
const proto = this[_getPrototype](ids, ancestors);
this[_applyPrototype](proto, ids, ancestors);
this[$resolvePrototypes](ids, ancestors);
[_getPrototype](ids, ancestors) {
let somExpression = null;
if (usehref.startsWith("#som(") && usehref.endsWith(")")) {
somExpression = usehref.slice("#som(".length, -1);
} else if (usehref.startsWith(".#som(") && usehref.endsWith(")")) {
somExpression = usehref.slice(".#som(".length, -1);
} else if (usehref.startsWith("#")) {
} else if (usehref.startsWith(".#")) {
} else if (use.startsWith("#")) {
this.use = this.usehref = "";
proto = searchNode(ids.get($root), this, somExpression, true, false);
warn(`XFA - Invalid prototype reference: ${ref}.`);
if (proto[$nodeName] !== this[$nodeName]) {
warn(`XFA - Incompatible prototype: ${proto[$nodeName]} !== ${this[$nodeName]}.`);
if (ancestors.has(proto)) {
warn(`XFA - Cycle detected in prototypes use.`);
const protoProto = proto[_getPrototype](ids, ancestors);
proto[_applyPrototype](protoProto, ids, ancestors);
proto[$resolvePrototypes](ids, ancestors);
[_applyPrototype](proto, ids, ancestors) {
if (ancestors.has(proto)) {
warn(`XFA - Cycle detected in prototypes use.`);
if (!this[$content] && proto[$content]) {
this[$content] = proto[$content];
const newAncestors = new Set(ancestors);
for (const unsetAttrName of this[_getUnsetAttributes](proto[_setAttributes])) {
this[unsetAttrName] = proto[unsetAttrName];
if (this[_setAttributes]) {
this[_setAttributes].add(unsetAttrName);
for (const name of Object.getOwnPropertyNames(this)) {
if (this[_attributeNames].has(name)) {
const value = this[name];
const protoValue = proto[name];
if (value instanceof XFAObjectArray) {
for (const child of value[_children]) {
child[_resolvePrototypesHelper](ids, ancestors);
for (let i = value[_children].length, ii = protoValue[_children].length; i < ii; i++) {
const child = proto[_children][i][$clone]();
this[_children].push(child);
child[_resolvePrototypesHelper](ids, ancestors);
value[$resolvePrototypes](ids, ancestors);
value[_applyPrototype](protoValue, ids, ancestors);
if (protoValue !== null) {
const child = protoValue[$clone]();
this[_children].push(child);
child[_resolvePrototypesHelper](ids, ancestors);
static [_cloneAttribute](obj) {
if (Array.isArray(obj)) {
return obj.map(x => XFAObject[_cloneAttribute](x));
if (typeof obj === "object" && obj !== null) {
return Object.assign({}, obj);
const clone = Object.create(Object.getPrototypeOf(this));
for (const $symbol of Object.getOwnPropertySymbols(this)) {
clone[$symbol] = this[$symbol];
shadow(clone, $symbol, this[$symbol]);
clone[$uid] = `${clone[$nodeName]}${uid++}`;
for (const name of Object.getOwnPropertyNames(this)) {
if (this[_attributeNames].has(name)) {
clone[name] = XFAObject[_cloneAttribute](this[name]);
const value = this[name];
clone[name] = value instanceof XFAObjectArray ? new XFAObjectArray(value[_max]) : null;
for (const child of this[_children]) {
const name = child[$nodeName];
const clonedChild = child[$clone]();
clone[_children].push(clonedChild);
clonedChild[_parent] = clone;
if (clone[name] === null) {
clone[name] = clonedChild;
clone[name][_children].push(clonedChild);
[$getChildren](name = null) {
return this[_children].filter(c => c[$nodeName] === name);
[$getChildrenByClass](name) {
[$getChildrenByName](name, allTransparent, first = true) {
return Array.from(this[$getChildrenByNameIt](name, allTransparent, first));
*[$getChildrenByNameIt](name, allTransparent, first = true) {
for (const child of this[_children]) {
if (child[$nodeName] === name) {
if (child.name === name) {
if (allTransparent || child[$isTransparent]()) {
yield* child[$getChildrenByNameIt](name, allTransparent, false);
if (first && this[_attributeNames].has(name)) {
yield new XFAAttribute(this, name, this[name]);
constructor(max = Infinity) {
const len = this[_children].length;
this[_children].push(child);
warn(`XFA - node "${child[$nodeName]}" accepts no more than ${this[_max]} children`);
return this[_children].length === 0;
return this[_children].length === 1 ? this[_children][0][$dump]() : this[_children].map(x => x[$dump]());
const clone = new XFAObjectArray(this[_max]);
clone[_children] = this[_children].map(c => c[$clone]());
this[_children].length = 0;
constructor(node, name, value) {
this[$uid] = `attribute${uid++}`;
return this[$content].trim();
value = value.value || "";
this[$content] = value.toString();