Skip to content

Commit

Permalink
Allow Builder instances to be passed as cnode parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
jcbrand committed Jan 17, 2025
1 parent b4f3369 commit f54d831
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Version 3.1.1 - (Unreleased)

- Strip unnecessary whitespace from `Stanza` elements
- Allow `Builder` instances to be passed into the `cnode` function
- Bugfix. Handle `null` and `undefined` values inside `stx` tagged template literals.

## Version 3.1.0 - (2024-12-16)
Expand Down
5 changes: 4 additions & 1 deletion src/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,13 @@ class Builder {
* name and an attributes object to create the child it uses an
* existing DOM element object.
*
* @param {Element} elem - A DOM element.
* @param {Element|Builder} elem - A DOM element.
* @return {Builder} The Strophe.Builder object.
*/
cnode(elem) {
if (elem instanceof Builder) {
elem = elem.tree();
}
let impNode;
const xmlGen = xmlGenerator();
try {
Expand Down
4 changes: 2 additions & 2 deletions src/types/builder.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ declare class Builder {
* name and an attributes object to create the child it uses an
* existing DOM element object.
*
* @param {Element} elem - A DOM element.
* @param {Element|Builder} elem - A DOM element.
* @return {Builder} The Strophe.Builder object.
*/
cnode(elem: Element): Builder;
cnode(elem: Element | Builder): Builder;
/**
* Add a child text element.
*
Expand Down

0 comments on commit f54d831

Please sign in to comment.