@sitecore-feaas/clientside 0.3.8 → 0.3.9

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.
@@ -82,14 +82,12 @@ export const parseProps = (propName: string, propValue: string, properties: JSON
82
82
  }
83
83
  }
84
84
 
85
- export function FEAASExternalProps(element: FEAASElement) {
86
- const attributes = element.getAttributeNames()
85
+ export function FEAASExternalProps(element: FEAASElement): any {
87
86
  const id = element.getAttribute('data-external-id')
88
87
  const schema: JSONSchema = FEAASExternal.registered[id]?.schema
89
- const props = attributes.reduce((prev, curr) => {
90
- if (!curr.startsWith('data-attribute') && !['class', 'id', 'contenteditable'].includes(curr)) {
91
- const value = element.getAttribute(curr)
92
- return { ...prev, [reverseKebabCase(curr)]: parseProps(reverseKebabCase(curr), value, schema?.properties) }
88
+ const props = Array.from(element.attributes).reduce((prev, { name, value }) => {
89
+ if (!name.startsWith('data-attribute') && !['class', 'id', 'contenteditable'].includes(name)) {
90
+ return { ...prev, [reverseKebabCase(name)]: parseProps(reverseKebabCase(name), value, schema?.properties) }
93
91
  } else {
94
92
  return prev
95
93
  }
package/src/ui/react.tsx CHANGED
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  FEAASComponentProps,
3
+ FEAASElement,
3
4
  fetchComponent,
4
5
  getComponentURL,
5
6
  getStylesheetURL,
@@ -9,7 +10,7 @@ import React from 'react'
9
10
  import { renderHTMLContent, HTMLNode, parseHTMLContent } from '../dom/html.js'
10
11
  import { DataSettings } from '../utils/settings.js'
11
12
  export { renderHTMLContent }
12
- import { getComponent } from './FEAASExternal.js'
13
+ import { FEAASExternalProps, getComponent } from './FEAASExternal.js'
13
14
  export { External, linkComponents, registerComponent, getComponent } from './FEAASExternal.js'
14
15
  export * from './index.js'
15
16
  export * from '../headless.js'
@@ -45,7 +46,8 @@ export function FEAASReactComponent({ data, ...props }: FEAASReactComponentProps
45
46
  node,
46
47
  (node) => {
47
48
  if (node.localName == 'feaas-external' && getComponent(node.getAttribute('data-external-id'))) {
48
- return [FEAASReactExternal, {}]
49
+ const { dataExternalId, ...props } = FEAASExternalProps(node as any)
50
+ return [FEAASReactExternal, props]
49
51
  }
50
52
  },
51
53
  index