Bug: page-cache.js:40 «Uncaught TypeError: element.prop is not a function»

How to fix

Replace the problem line with the new one:

.prop('href', element.src)

Description

The element is a HTMLIFrameElement, it does not have the prop() method, but had the src property.

1 Like

See Also: GitHub Pull Request #4022
https://github.com/magento/magento2/pull/4022

I have the latest version of Magento 2, and when I add my own iframe to a block, I get the exact same error. Also, the code in my version looks like

.prop('href', element.prop('src'))

So I’ll have to change it to the suggested code above

.prop('href', element.src)

Let’s see if this fixes it :slight_smile:

1 Like

And now the bug has disappeared after applying the patch to page-cache.js located in /vendor/magento/module-page-cache/view/frontend/web/js/

Is this really a bug it only happens when I loaded external libraries with requireJs.
Indeed I apply this patch and it fixes the error on Magento 2.1.4 .
Thank you.

It has been fixed on 2017-02-17 in the Magento 2.2 development branch:

https://github.com/magento/magento2/commit/4cd69b8b9c8c5adff4200d29fc5e89d08b9a451f#diff-ae1424960583c29267a62a256f74ac81

https://github.com/magento/magento2/blob/4cd69b8/app/code/Magento/PageCache/view/frontend/web/js/page-cache.js#L40-L70