@sswroom/sswr 1.6.14 → 1.6.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/web.d.ts CHANGED
@@ -115,6 +115,8 @@ export function getSelectElement(id: string): HTMLSelectElement;
115
115
  export function getButtonElement(id: string): HTMLButtonElement;
116
116
  export function getDivElement(id: string): HTMLDivElement;
117
117
  export function getSpanElement(id: string): HTMLSpanElement;
118
+ export function getCanvasElement(id: string): HTMLCanvasElement;
119
+ export function getImgElement(id: string): HTMLImageElement;
118
120
  export function getBrowserInfo(): Promise<BrowserInfo>;
119
121
  export function parseUserAgent(userAgent: string): BrowserInfo;
120
122
 
package/web.js CHANGED
@@ -1006,6 +1006,34 @@ export function getSpanElement(id)
1006
1006
  throw new Error("Element with id \""+id+"\" is not a span");
1007
1007
  }
1008
1008
 
1009
+ /**
1010
+ * @param {string} id
1011
+ * @returns {HTMLCanvasElement}
1012
+ */
1013
+ export function getCanvasElement(id)
1014
+ {
1015
+ let ele = document.getElementById(id);
1016
+ if (ele == null)
1017
+ throw new Error("Element with id \""+id+"\" not found");
1018
+ if (ele instanceof HTMLCanvasElement)
1019
+ return ele;
1020
+ throw new Error("Element with id \""+id+"\" is not a canvas");
1021
+ }
1022
+
1023
+ /**
1024
+ * @param {string} id
1025
+ * @returns {HTMLImageElement}
1026
+ */
1027
+ export function getImgElement(id)
1028
+ {
1029
+ let ele = document.getElementById(id);
1030
+ if (ele == null)
1031
+ throw new Error("Element with id \""+id+"\" not found");
1032
+ if (ele instanceof HTMLImageElement)
1033
+ return ele;
1034
+ throw new Error("Element with id \""+id+"\" is not an img");
1035
+ }
1036
+
1009
1037
  /**
1010
1038
  * @returns {Promise<{os: String,osVer?:string,browser: String,browserVer?: string,devName?:string}>}
1011
1039
  */