vaderjs 2.2.4 → 2.2.5

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/document/index.ts CHANGED
@@ -1,11 +1,24 @@
1
+ //@ts-nocheck
2
+ const acceptedAttributes = [
3
+ // Global attributes
4
+ 'accesskey', 'class', 'className', 'idKey', 'contenteditable', 'contextmenu', 'data', 'dir', 'hidden',
5
+ 'id', 'lang', 'style', 'tabindex', 'title', 'translate', 'xml:lang', 'xml:space',
6
+
7
+ // SVG-specific attributes
8
+ 'xmlns', 'fill', 'viewBox', 'stroke-width', 'stroke', 'd', 'stroke-linecap', 'stroke-linejoin', 'content', 'name'
9
+ ];
1
10
  export const document = (element: any) => {
11
+ if(!element) return ``
2
12
  let type = element.type;
3
13
  let el = type === null ? `` : `<${type}`
4
14
  let attributes = element.props;
5
15
  let children = element.children;
6
16
  if(type != null && type !== false && type !== true && type !== undefined){
7
17
  for (let key in attributes) {
8
- if(key === "key"){
18
+ if (typeof attributes[key] !== "string" || !acceptedAttributes.includes(key)) {
19
+ continue;
20
+ }
21
+ if(key === "key"){
9
22
  el += ` key="${attributes[key]}"`;
10
23
  continue;
11
24
  }
package/index.ts CHANGED
@@ -233,6 +233,16 @@ interface SwitchProps {
233
233
  children: any[] | any;
234
234
  }
235
235
 
236
+ const acceptedAttributes = [
237
+ // Global attributes
238
+ 'accesskey', 'class', 'className', 'idKey', 'contenteditable', 'contextmenu', 'data', 'dir', 'hidden',
239
+ 'id', 'lang', 'style', 'tabindex', 'title', 'translate', 'xml:lang', 'xml:space',
240
+
241
+ // SVG-specific attributes
242
+ 'xmlns', 'fill', 'viewBox', 'stroke-width', 'stroke', 'd', 'stroke-linecap', 'stroke-linejoin', 'content', 'name'
243
+ ];
244
+
245
+
236
246
  // make children optional
237
247
  export function Switch({ children = [] }: SwitchProps) {
238
248
  for (let child of children) {
@@ -663,7 +673,8 @@ export class Component {
663
673
 
664
674
  // Set attributes
665
675
  let attributes = element.props || {};
666
- for (let key in attributes) {
676
+ for (let key in attributes) {
677
+ if(typeof attributes[key] !== "string" && !acceptedAttributes.includes(key) || !acceptedAttributes.includes(key)) continue;
667
678
  if(key === "ref") {
668
679
  let _key = attributes[key].key;
669
680
  // update the ref
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vaderjs",
3
- "version": "2.2.4",
3
+ "version": "2.2.5",
4
4
  "description": "A simple and powerful JavaScript library for building modern web applications.",
5
5
  "bin": {
6
6
  "vaderjs": "./main.js"