Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't Retrieve HTMLCollection Object #1058

Open
3 tasks done
Vladeouz opened this issue Jun 24, 2024 · 1 comment
Open
3 tasks done

Can't Retrieve HTMLCollection Object #1058

Vladeouz opened this issue Jun 24, 2024 · 1 comment

Comments

@Vladeouz
Copy link

Bug Report

Im trying to accessing the data inside of HTMLCollection.

Problem

I cant accessing it, and retrieve the data.

What is expected to happen?

it should return the data inside the HTMLCollection

What does actually happen?

It always gives null.

Information

this is the result of the print
image

Command or Code

InAppBrowserRef.executeScript({ code:
console.log('masuk di script');
window.addEventListener('DOMContentLoaded', function () {
console.log('Im here 1');
});
document.addEventListener('DOMContentLoaded', function () {
console.log('Im here 2');
});
window.addEventListener('load', function () {
console.log('Im here 3');
});
document.addEventListener('load', function () {
console.log('Im here 4');
});
const elements = document.querySelectorAll(".text-grey");
console.log('this is elements', elements);
console.log('this is the lengthnya', elements.length);
console.log('trying to open the 0 index', elements.item(0));
const newArray = Array.from(elements);
console.log('this is the new Array', newArray);
newArray.forEach(function (element) {
console.log('result of forEach', element);
});
Array.from(elements).forEach((element) => {
console.log(element.innerText)
});
}, function (result) { console.log('Script Executed:', result) }) }

Environment, Platform, Device

Samsung A50s Android 11

Version information

Operating System - Windows_NT(10.0.22631) - win32/x64
NodeJs - 16.20.1

Global packages
NPM - 8.19.4
yarn - 1.22.19
@quasar/cli - 1.3.2
cordova - 12.0.0 (cordova-lib@12.0.1)

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above
@breautek
Copy link
Contributor

I do not believe that this is an issue with the in-app-browser.

Cordova doesn't implement browser features, and HTMLCollection / document.querySelectorAll is a browser feature implemented by the webview.

HTMLCollection is a "live" object which means it can change, it's reflective of the DOM state, so if the DOM state changes, so will the HTMLCollection object. It is weird that it appears to change within script execution though. By the time it reaches console.log('this is the lengthnya', elements.length);, it shows that the collection is empty, so naturally elements.item(0) would return null.

Are you sure that the DOM nodes isn't being manipulated and your .text-area nodes aren't being removed from the DOM?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants