Expand my Community achievements bar.

Adobe Summit 2025: AEM Session Recordings Are Live! Missed a session or want to revisit your favorites? Watch the latest recordings now.

Image width renditions breaks when using Vue.js

Avatar

Level 1

The image width renditions functionality of the image core component breaks when using with Vue.js

The error says as follows

 

 

Uncaught TypeError: Cannot read property 'removeAttribute' of null
    at unwrapNoScript (clientlib-base.js:1877)
    at init (clientlib-base.js:1797)
    at new Image (clientlib-base.js:2000)
    at HTMLDocument.onDocumentReady (clientlib-base.js:2007)

 

 

The error happens right here.

The div with the id app is being used as the Vue main template. This Vue template encompass the whole page body of the page core component.

 

 

<div data-sly-attribute.id="app" data-sly-use.templatedContainer="com.day.cq.wcm.foundation.TemplatedContainer"
         data-sly-repeat.child="${templatedContainer.structureResources}"
         data-sly-resource="${child.path @ resourceType=child.resourceType, decorationTagName='div'}"></div>

 

 

Tracing down the problem I found that the Vue.js is changing the HTML of the nonscript tag generated by the image core component, stripping off the white spaces that the component generates. When the clientlib of the image core component tries to get the generated tag image, it uses the textContent of the element as follows that._elements.noscript.textContent.trim() , but it retrieves and empty text instead of the text with the image tag, because Vue had previously removed the white spaces. This causes the clientlib to break here.

Here the link to reproduce the issue.

https://jsfiddle.net/herbergt/xgtzya5k/16/

Any workaround to solve this?

 

 

 

2 Replies

Avatar

Community Advisor

Hi

 

One option you can try is to override the imageimpl for v2 and see the required items are non null.

 

Another option might be to check the behavior for the later image v3 core component.

 

Thanks


Shubham

Avatar

Administrator

@herbergt Did you find the suggestion helpful? Please let us know if you need more information. If a response worked, kindly mark it as correct for posterity; alternatively, if you found a solution yourself, we’d appreciate it if you could share it with the community. Thank you!



Kautuk Sahni