You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Removing the keyword new fixes the problem. Additionally, the function could get imported with the original name (initial lowercase) to avoid confusions too.
I don't know why this utility was being used that way. I checked the module history back to it's origin at 2015 and was a normal function (not a constructor), but maybe that came from a refactor at another module implemented differently; anyway, it's a long way is not a constructor so I think the proposed change should be compatible with any recent and supported cordova/cordova-android version, or Am I missing something?
Expected Behaviour
Compile without errors
Actual Behaviour
Doesn't compile
Reproduce Scenario (including but not limited to)
Modern Cordova app.
Steps to Reproduce
Create Cordova APP, add plugin, compile.
Platform and Version (eg. Android 5.0 or iOS 9.2.1)
Internally, uses cordova-common version 4.1.0. Per their commit log, a refactor on that module causes that the function cannot be call as a constructor (using method notation on a plain object rather than assigning a function as property). Per the implementation of that function, now and on previous versions, is not needed at all call it as a constructor (I don't know it that's was different at some point in the past).
NodeJS v14.17.0 (the V8 engine is responsible for limiting the way the function is executed, so the source error message comes from it).
Would you be able to upgrade your project to the latest version of the plugin and Cordova-Android (13.0.0)?
The current 4.x release of the plugin requires Cordova-Android 12.0.0 or higher as a minimum. The beforeCompile hook script was initially created to support Cordova-Android 9.x, but with the increased minimum requirement to 12.0.0 in 4.x, this script is no longer needed. It will be removed in the upcoming 5.0.0 release, as it was mistakenly left in the previous version.
I generally try to avoid modifying an older major release when a new version is available.
If you’re still using Cordova-Android 9.x and Push Plugin 3.x, is there a specific reason for maintaining this setup?
Bug Report
Error at compilation because
ParseElementtreeSync is not a constructor
.That function is an alias for the utility
parseElementtreeSync
fromcordova-common//src/util/xml-helpers
.Is called as a constructor here.
Proposed solution
Removing the keyword
new
fixes the problem. Additionally, the function could get imported with the original name (initial lowercase) to avoid confusions too.I don't know why this utility was being used that way. I checked the module history back to it's origin at 2015 and was a normal function (not a constructor), but maybe that came from a refactor at another module implemented differently; anyway, it's a long way is not a constructor so I think the proposed change should be compatible with any recent and supported cordova/cordova-android version, or Am I missing something?
Expected Behaviour
Compile without errors
Actual Behaviour
Doesn't compile
Reproduce Scenario (including but not limited to)
Modern Cordova app.
Steps to Reproduce
Create Cordova APP, add plugin, compile.
Platform and Version (eg. Android 5.0 or iOS 9.2.1)
Tarket SDK 31 / Android 12.
And for Cordova
Internally, uses
cordova-common
version 4.1.0. Per their commit log, a refactor on that module causes that the function cannot be call as a constructor (using method notation on a plain object rather than assigning a function as property). Per the implementation of that function, now and on previous versions, is not needed at all call it as a constructor (I don't know it that's was different at some point in the past).NodeJS v14.17.0 (the V8 engine is responsible for limiting the way the function is executed, so the source error message comes from it).
(Android) Device Vendor (e.g. Samsung, HTC, Sony...)
N/A
cordova info
PrintoutThe text was updated successfully, but these errors were encountered: