Fix: Uncaught TypeError: evt.target.hasAttribute is not a function
MODIFY
README.md
README.md
@@ -78,6 +78,7 @@ Check out the latest version <a href="https://developer.android.com/topic/librar
## Release Notes
- **v2.3.5**
- Fix: `cordova.fireDocumentEvent('plugin_touch', {})` blocks HTML DOM tree parsing process.
+ - Fix: `Uncaught TypeError: evt.target.hasAttribute is not a function` when device is rotated.
- **v2.3.4**
- Fix: plugin does not recognize HTML elements correctly after moving HTML elements with animations

MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.3.5-beta-20180525-1043" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
+<plugin id="cordova-plugin-googlemaps" version="2.3.5-beta-20180528-1726" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>cordova-plugin-googlemaps</name>
<js-module name="BaseClass" src="www/BaseClass.js">
<runs />

MODIFY
www/googlemaps-cdv-plugin.js
www/googlemaps-cdv-plugin.js
@@ -60,6 +60,9 @@ if (!cordova) {
var transformTargets = {};
var transitionCnt = 0;
function followMaps(evt) {
+ if (cordovaGoogleMaps.MAP_CNT === 0) {
+ return;
+ }
transitionCnt++;
cordovaGoogleMaps.transforming = true;
var changes = cordovaGoogleMaps.followMapDivPositionOnly.call(cordovaGoogleMaps);
@@ -77,11 +80,12 @@ if (!cordova) {
// CSS event `transitionend` is fired even the target dom element is still moving.
// In order to detect "correct demention after the transform", wait until stable.
function onTransitionEnd(evt) {
- if (!evt || !evt.target ||!evt.target.hasAttribute("__pluginDomId")) {
+ if (cordovaGoogleMaps.MAP_CNT === 0 || !evt) {
return;
}
- var elemId = evt.target.getAttribute("__pluginDomId");
- transformTargets[elemId] = {left: -1, top: -1, right: -1, bottom: -1, finish: false, target: evt.target};
+ var target = evt.target.getAttribute === "function" ? evt.target : document.body;
+ var elemId = target.getAttribute("__pluginDomId");
+ transformTargets[elemId] = {left: -1, top: -1, right: -1, bottom: -1, finish: false, target: target};
if (!transitionEndTimer) {
transitionEndTimer = setTimeout(detectTransitionFinish, 100);
}
@@ -125,7 +129,7 @@ if (!cordova) {
}
function onTransitionFinish() {
- if (!cordovaGoogleMaps.transforming) {
+ if (cordovaGoogleMaps.MAP_CNT === 0 || !cordovaGoogleMaps.transforming) {
return;
}
cordovaGoogleMaps.transforming = false;

Fix: Uncaught TypeError: evt.target.hasAttribute is not a function #2293