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

QtWebKit: jQuery thinks that DOM elements collection is a function #4756

Closed
natipo opened this issue Jul 21, 2020 · 2 comments
Closed

QtWebKit: jQuery thinks that DOM elements collection is a function #4756

natipo opened this issue Jul 21, 2020 · 2 comments

Comments

@natipo
Copy link

natipo commented Jul 21, 2020

Description

After upgrade from jQuery 3.2.1 to 3.3.0 wkhtmltopdf tool stopped working due to the following error in jQuery:

TypeError: 'undefined' is not a function (evaluating 'e.getAttribute("type")')

Browser to reproduce: QtWeb 3.8.5 (http://www.qtweb.net/)

The actual problem is inside isFunction( obj ). The current fix for web browsers where DOM nodes are being classified as a function is not enough for QtWebKit because types such as NodeList or HTMLCollection don't have attribute nodeType and the typeof command returns function.

Output using QtWeb JavaScript console:

> typeof document.getElementsByTagName("p")
"function"
> document.getElementsByTagName("p").nodeType
undefined
> document.getElementsByTagName("p").toString()
"[object NodeList]"

Many systems depend on this wkhtmltopdf tool in terms of converting HTML page to PDF. Since jQuery 4 is about to drop support for old browsers, I would like to bring back support for QtWebKit 4 in jQuery 3.x so I could upgrade the system to the latest and secure version of jQuery 3.x.

Link to test case

  1. Create a simple index.html page.
<!DOCTYPE html>
<html>
	<head>
		<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
		<script type="text/javascript">
			$( document ).ready(function() {				
				$( "p" ).append( "<p>My second paragraph.</p>" );
			});
		</script>
	</head> 
	<body>
		<h1>My First Heading</h1>
		<p>My first paragraph.</p>
	</body>
</html>
  1. Download portable version of QtWeb 3.8.5 (http://www.qtweb.net/download.html)
  2. Open above page in QtWeb and notice that second paragraph tag is not added, but it should be.
  3. Additionally you may enable console in QtWeb Tools -> Enable Web Inspector in order to see error details.
natipo added a commit to natipo/jquery that referenced this issue Jul 21, 2020
Fix allows jQuery to recognize that DOM types such as HTMLCollection
or NodeList are not functions.

Fixes jquerygh-4756
@mgol mgol added the Discuss in Meeting Reserved for Issues and PRs that anyone would like to discuss in the weekly meeting. label Jul 21, 2020
@mgol
Copy link
Member

mgol commented Jul 21, 2020

Thanks for the report. We don't support QtWebKit but I'm not opposed to a simple patch just for the 3.x line if it's all that's needed.

For reference, the commit that caused this issue is a16339b. See the linked issues for an explanation about the change.

natipo added a commit to natipo/jquery that referenced this issue Jul 22, 2020
Fix allows jQuery to recognize that DOM types such as HTMLCollection
or NodeList are not functions.

Code review changes:
- use toString from jQuery instead of native
- add support comment mentioning affected environments & their versions

Fixes jquerygh-4756
natipo added a commit to natipo/jquery that referenced this issue Jul 22, 2020
Fix allows jQuery to recognize that DOM types such as HTMLCollection
or NodeList are not functions.

Code review changes:
- use toString from jQuery instead of native
- improve support comment

Fixes jquerygh-4756
natipo added a commit to natipo/jquery that referenced this issue Jul 22, 2020
Fix allows jQuery to recognize that DOM types such as HTMLCollection
or NodeList are not functions.

Code review changes:
- fix toString dependency definition

Fixes jquerygh-4756
mgol pushed a commit that referenced this issue Jul 27, 2020
Allow jQuery to recognize that DOM types such as HTMLCollection
or NodeList are not functions.

Fixes gh-4756
Closes gh-4757
@mgol
Copy link
Member

mgol commented Jul 27, 2020

Fixed by #4757.

@mgol mgol closed this as completed Jul 27, 2020
@mgol mgol added this to the 3.6.0 milestone Jul 27, 2020
@mgol mgol removed the Discuss in Meeting Reserved for Issues and PRs that anyone would like to discuss in the weekly meeting. label Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants