Bug Tracker

Opened 7 years ago

Closed 6 years ago

#12905 closed bug (notabug)

jqery 1.8.2: Uncaught TypeError: Object #<Text> has no method 'getAttribute'

Reported by: marc.boehret@… Owned by: marc.boehret@…
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.3
Keywords: Cc:
Blocked by: Blocking:

Description

  1. the following code leads to Uncaught TypeError: Object #<Text> has no method 'getAttribute'
  2. fixed it locally by adding "typeof(b.getAttribute) == 'function'" check
  3. started since jquery 1.8, in jQuery 1.7.2 it was working fine
  1. code example

$('#TestLink').live('click', function() {

console.log('click'); testLink = $(this); targetUrl = testLink.attr('href'); $.ajax({

url: targetUrl, success: function(data) {

console.log('ajax success'); dataElement = $(data); dataElement.is("#main-content");

}

}); return false;

});

  1. my local fix in jquery 1.8.2

filter: {

ID: d ? function(a) {

return a = a.replace(V, ""), function(b) {

return typeof(b.getAttribute) == 'function' && b.getAttribute("id") === a

}

} : function(a) {

return a = a.replace(V, ""), function(b) {

var c = typeof b.getAttributeNode !== n && b.getAttributeNode("id"); return c && c.value === a

}

},

Change History (4)

comment:1 Changed 7 years ago by marc.boehret@…

i wanted to use jsFiddle but it does not work for ajax-requests for some reason.

http://jsfiddle.net/gLjdg/19/

comment:2 Changed 7 years ago by dmethvin

Owner: set to marc.boehret@…
Status: newpending

Which browser gave you the error?

Does the ajax really have anything to do with it? It seems like the problem would be with the id selection. Please reduce this further.

comment:3 Changed 7 years ago by marc.boehret@…

Status: pendingnew

I was checking if it is browser-specific but the exception raised on firefox and on google chrome - in safari and others i didn't check.

I can give you the return object of the ajax call.


Real Code Example

http://pastie.org/5390982

comment:4 Changed 6 years ago by dmethvin

Resolution: notabug
Status: newclosed

Sorry but it's not possible to debug the problem given what's been presented here. Please ask someone to help you debug this in our forum or on StackOverflow and create a new bug with a specific and reduced test case if you can.

In the code above, the dataElement = $(data) stands out as particularly flakey but I don't want to start a blind debugging session in the bug tracker.

Note: See TracTickets for help on using tickets.