Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

CCA: Component metadata needs stringification?

Venkata Rahul SJan 26 2022

I am doing my first Custom Web Component. All went well until the component registration (during the build). During the actual service, the

Composite.register("nheader", {
  view: view,
  viewModel: viewModel,
  metadata: JSON.parse(metadata)
});

call in the loader.ts failed with a JSON parse error:
Uncaught SyntaxError: JSON.parse: unexpected character at line 1 column 2 of the JSON data
I tried modifying the above code with the following:

Composite.register("nheader", {
  view: view,
  viewModel: viewModel,
  metadata: JSON.parse(JSON.stringify(metadata))
});

Now the error is gone and the page gets served without issues. Most possibly a scripting engine issue. I am using the Firefox Dev edition.

I see some changes in the component generation and documentation:
Please rename the metadata import as rawmetadata (for clarity) in the loader.ts
Please consider the stringification done as above, so that code works on all browsers. Or my understanding could be corrected. Please comment.
The component registration (along with its version) both as a standalone or as part of a pack happens automatically at build time. Can this fact be added to the CCA documentation please? There seems to be some disconnect here because I spent two days understanding how this wiring happens. Perhaps here?

Comments

Processing

Post Details

Added on Jan 26 2022
2 comments
401 views