thunderbird / developer-docs

Developer documentation for Thunderbird contributors.
https://developer.thunderbird.net
82 stars 77 forks source link

TB 68 -> 78 page should discuss removal of document.getAnonymousElementByAttribute() #94

Closed eyalroz closed 4 years ago

eyalroz commented 4 years ago

An important API function removed over the past year is document.getAnonymousElementByAttribute().

See: https://bugzilla.mozilla.org/show_bug.cgi?id=1591145

The TB 68->78 changes pages should discuss this and suggest an alternative.

jobisoft commented 4 years ago

That is part of the XBL removal which was done in TB68. This is currently above my head. What did you use it for?

eyalroz commented 4 years ago

It was part of this piece of code which tried several ways of getting the message subject, each of which worked with different versions of TB or SM. The removal happened in TB 72 according to the bug page.

jobisoft commented 4 years ago

This document which is linked in the TB68 guide has some info about this: https://wiki.mozilla.org/Thunderbird/de-xbl

Is that sufficient?

eyalroz commented 4 years ago

@jobisoft : No, because :

  1. extension authors don't use that method only for their own XBL elements. They may think of it as merely another DOM search utility.
  2. Because this removal is a 68->78 change.
  3. Because, glancing at that document, it's not at all clear that this is a change to notice. The TB 68->78 changes page has a nice header with each removed API.
jobisoft commented 4 years ago

It was part of this piece of code

Which code? Can you link?

jobisoft commented 4 years ago

I am not saying you are wrong. But it appears the removed function in TB72 was already "dead code" (always returned null pointer) so the functionality stopped long ago. With TB72 it would throw now that an unknown function has been used.

This is obviously a function related to XBL.

eyalroz commented 4 years ago

@jobisoft : this. It was already failing in what it was trying to do in v68, but it didn't throw an exception. Also, it was necessary/useful in earlier versions.

For the last few years, what really needs to be used is

displayedMessageSubject = document.getElementById('expandedsubjectBox').textContent;

but for multi-version-support, one needs both the exists code and this line as yet another alternative.

jobisoft commented 4 years ago

So my assumption is true :-)

Woohoo: A lot of add-ons are still using that: https://github.com/search?q=getAnonymousElementByAttribute++path:/xall/x68+repo%3Acleidigh%2FThunderKdB&type=Code

So what did you use it for? Why not just use getElementById or something?

eyalroz commented 4 years ago

So what did you use it for? Why not just use getElementById or something?

The field with the text used to be an anonymous element within the XBL subject box. So, I couldn't get it byId().

jobisoft commented 4 years ago

https://developer.thunderbird.net/add-ons/updating/tb78/changes#getanonymouselementbyattribute-and-getanonymousnodes-have-been-removed

I do not think there is more to say, is there?

eyalroz commented 4 years ago

I do not think there is more to say, is there?

Well:

  1. If this stopped working in TB 68, perhaps there needs to be a note about these in the TB 68 document.
  2. The links you added are to the German version of the documentation.
jobisoft commented 4 years ago
  1. I think it is, isn't it? There is a section about Removed XBL bindings and there is a linked document which includes the removal/replacement of getAnonymousElementByAttribute

  2. Thanks! That happens way to often. Fixed.

eyalroz commented 4 years ago
  1. I think it is, isn't it? There is a section about Removed XBL bindings and there is a linked document which includes the removal/replacement of getAnonymousElementByAttribute

Well, not effectively. I mean, there is nothing inherently XBL'ish about a method named getAnonymousElementByAttribute(). When I was updating my extensions for TB 68 it didn't occur to me that to follow that link, since I as far as I was concerned, I wasn't using any XBL. (And I didn't get the error because it was being masked by something else.)

mkmelin commented 4 years ago

Maybe it's not apparent, but the whole concept of anonymous content is (was) XBL only.

jobisoft commented 4 years ago

Hm, the very first google search result of "MDN getAnonymousElementByAttribute()" returns:

https://developer.mozilla.org/en-US/docs/Archive/Mozilla/XBL/XBL_1.0_Reference/DOM_Interfaces

which tells you this method belongs to the XBL stuff. I hesitate to duplicate the information ...

eyalroz commented 4 years ago

I hesitate to duplicate the information ...

There's no problem with a bit of duplication between the 78-changes page and other pages which describe these changes in a different context. But it's your call I guess.

@mkmelin : I understand this now, but it's not obvious from the method name. I had originally copy-pasted some code which used getAnonymousElementByAttribute(), and with the passage of time had not remembered that code may have had something to do with XBL.

jobisoft commented 4 years ago

We are talking about duplication inside the TB68 add-on guide. I did add the info to the TB78 guide, as it throws errors now.

Let me sleep over this. I probably extend the info box in the TB68 guide.

jobisoft commented 4 years ago

https://developer.thunderbird.net/add-ons/updating/tb68/changes#removed-xbl-bindings

eyalroz commented 4 years ago

I can live with that.