aframe icon indicating copy to clipboard operation
aframe copied to clipboard

Schema of single-property component with custom type requires default

Open rockwalrus opened this issue 3 years ago • 3 comments

Description:

  • A-Frame Version: 1.3.0
  • Platform / Device: N/A
  • Reproducible Code Snippet or URL:
AFRAME.registerComponent("example", {
  schema: {
    parse(value) {
      return value;
    },
    stringify(value) {
      return value.toString();
    }
  }
});

If you try to create a single-property component with a custom type, it will try to interpret the schema as a multiple-property component (with poor results) unless a default key is also present. It seems to only look for the type and default keys when deciding if a component is multiple property or single property.

rockwalrus avatar Jul 19 '22 17:07 rockwalrus

Yeah default is necessary (probably we should elaborate on docs). After adding a default is it working for your use case?

dmarcos avatar Jul 21 '22 23:07 dmarcos

It works, more or less. The property is required, but I was able to just make the default invalid. It's not elegant, but it does the job.

rockwalrus avatar Jul 22 '22 00:07 rockwalrus

Thanks for the info. What do you mean by default invalid? Can you show the full code for the property? Thanks

dmarcos avatar Jul 27 '22 09:07 dmarcos

Closing due to inactivity. Can reopen if necessary

dmarcos avatar Nov 21 '22 01:11 dmarcos