kontent-ai / delivery-sdk-js

Kontent Delivery SDK for Javascript
https://kontent.ai
MIT License
50 stars 34 forks source link

Resolved content items are still within <object> tag #332

Closed ondrabus closed 2 years ago

ondrabus commented 2 years ago

Brief bug description

After resolving rich text elements, the tag describing the external resource persists.

Repro steps

  1. Resolve any rich text element
  2. The resolved content is still within the tag that now also contains the data-sdk-resolved attribute

    Expected behavior

    Once an external resource gets resolved, the tag should be replaced with the resolved content. According to https://www.w3schools.com/tags/tag_object.asp the tag is supposed to mark only external content, not resolved data.

    Additional context

    Currently, the problem can be mitigated using the following regex: .replace(/<object.?data-sdk-resolved=\"1\".?>(.*?)<\/object>/ms, '$1') However, it's not a good practice to keep code fixes of SDK issues in the project code not to mention the external dependencies (the use of "" tag and data-sdk-resolved attribute).

    ondrabus commented 2 years ago

    @Enngage any updates on this?

    Enngage commented 2 years ago

    @ondrabus I'm still not sure whether to use this or not. It's also a major change (unless we make this optional). The regex seems quite simple, but what if you want to use "object" within the resolver? I'm just not sure ;) @Simply007 has any opinion on this?

    ondrabus commented 2 years ago

    @Enngage I'm not saying it's the best solution :-) it's just a temp workaround that doesn't look good. Feel free to propose a better solution. I just want to get the problem that clearly exists solved :-)

    Simply007 commented 2 years ago

    @ondrabus I'm still not sure whether to use this or not. It's also a major change (unless we make this optional). The regex seems quite simple, but what if you want to use "object" within the resolver? I'm just not sure ;) @Simply007 has any opinion on this?

    I would expect that <object> tag would be replaced by the resolution. On the other hand there are already people that used the resolver and they might expect to have the <object> tag being in the resolved HTML (i.e. they have some CSS selectors depending on it).

    So I would choose between making it configurable, or changing the behavior (which is by the book breaking change).

    ondrabus commented 2 years ago

    @Enngage any updates on this?

    Enngage commented 2 years ago

    Will be released in next version. Currently, all tags are removed by default. You can however set preserveResolvedObjectTags of resolveRichText method to preserve tags if needed.