lemonmade / watch

Apache License 2.0
3 stars 0 forks source link

Is it possible to pass object from iframe to host? #320

Closed mohebifar closed 2 months ago

mohebifar commented 2 months ago

I'm trying to define an object prop and receive it in the host implementation of the element, however, I receive a [object Object] string in the host.

I've tried defining my own RemoteElementPropertyType, but I only see parse being invoked with [object Object].

export const RemoteObject: RemoteElementPropertyType<object> = {
  parse(value: string) {
    console.log("parse -->", value);
    return JSON.parse(value);
  },
  serialize(value: object) {
    console.log("serialize --->", value);
    return JSON.stringify(value);
  },
};

const BoxElement = createRemoteElement<RemoteBoxProps>({
  properties: {
    color: {
      type: String,
    },
    padding: {
      type: String,
    },
    rounded: {
      type: String,
    },
    style: {
      type: RemoteObject,
    },
  },
});