Skip to content

Commit

Permalink
Fix type error and regenerate types.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcbrand committed Dec 12, 2024
1 parent c6eae34 commit 82bf4a3
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/types/builder.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ declare class Builder {
* @return {Builder} The Strophe.Builder object.
*/
attrs(moreattrs: {
[x: string]: string | number | null;
[x: string]: string | number;
}): Builder;
/**
* Add a child to the current element and make it the new current
Expand Down
2 changes: 1 addition & 1 deletion src/types/connection.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ declare class Connection {
do_session: boolean;
/** @type {Object.<string, SASLMechanism>} */
mechanisms: {
[x: string]: SASLMechanism;
[x: string]: import("./sasl.js").default;
};
/** @type {TimedHandler[]} */
timedHandlers: TimedHandler[];
Expand Down
2 changes: 1 addition & 1 deletion src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export const Strophe: {
fatal(msg: string): void;
handleError(e: Error): void;
utf16to8(str: string): string;
xorArrayBuffers(x: ArrayBufferLike, y: ArrayBufferLike): ArrayBufferLike;
xorArrayBuffers(x: ArrayBufferLike, y: ArrayBufferLike): ArrayBuffer;
arrayBufToBase64(buffer: ArrayBufferLike): string;
base64ToArrayBuf(str: string): ArrayBufferLike;
stringToArrayBuf(str: string): ArrayBufferLike;
Expand Down
2 changes: 1 addition & 1 deletion src/types/utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function utf16to8(str: string): string;
* @param {ArrayBufferLike} x
* @param {ArrayBufferLike} y
*/
export function xorArrayBuffers(x: ArrayBufferLike, y: ArrayBufferLike): ArrayBufferLike;
export function xorArrayBuffers(x: ArrayBufferLike, y: ArrayBufferLike): ArrayBuffer;
/**
* @param {ArrayBufferLike} buffer
* @return {string}
Expand Down
13 changes: 6 additions & 7 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,17 +492,16 @@ export function isTagEqual(el, name) {
* @return {string} - A String with the concatenated text of all text element children.
*/
export function getText(elem) {
if (!elem) {
return null;
}
if (!elem) return null;

let str = '';
if (!elem.childNodes?.length && elem.nodeType === ElementType.TEXT) {
if (!elem.childNodes.length && elem.nodeType === ElementType.TEXT) {
str += elem.nodeValue;
}
for (let i = 0; i < elem.childNodes?.length ?? 0; i++) {
if (elem.childNodes[i].nodeType === ElementType.TEXT) {
str += elem.childNodes[i].nodeValue;

for (const child of elem.childNodes) {
if (child.nodeType === ElementType.TEXT) {
str += child.nodeValue;
}
}
return xmlescape(str);
Expand Down

0 comments on commit 82bf4a3

Please sign in to comment.