The default bug view has changed. See this FAQ.

Fix unfortunate design decision of tab.attach

NEW
Unassigned

Status

Add-on SDK
General
P2
normal
5 years ago
2 years ago

People

(Reporter: irakli, Unassigned)

Tracking

(Blocks: 1 bug)

unspecified
Future

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Unfortunate design choice of `Tab` API `tab.attach()` makes tabs aware of `page-mods`. It would be a much better if we had `pageMod.attachTo(documentOwner)` where `documentOwner` could be anything that has namespaced `document` property a la: 

`owner(documentOwner).document`

Maybe we still can implement new API and deprecate old one, which later can be removed (In 2.0 maybe) ?

Updated

5 years ago
OS: Mac OS X → All
Priority: -- → P2
Hardware: x86 → All
Target Milestone: --- → Future
(In reply to Irakli Gozilalishvili [:irakli] [:gozala] from comment #0)
> Unfortunate design choice of `Tab` API `tab.attach()` makes tabs aware of
> `page-mods`.

I'm not sure it is very relevant to design our public API based on internal code constraints. We should focus on exposing an API that make sense, and avoid making it more important to ease our implementation.

I can buy that tab.attach may not be the best API, but in bug's comment I'm only reading ease of implementation motivation.
(In reply to Alexandre Poirot (:ochameau) from comment #1)
> (In reply to Irakli Gozilalishvili [:irakli] [:gozala] from comment #0)
> > Unfortunate design choice of `Tab` API `tab.attach()` makes tabs aware of
> > `page-mods`.
> 
> I'm not sure it is very relevant to design our public API based on internal
> code constraints. We should focus on exposing an API that make sense, and
> avoid making it more important to ease our implementation.
> 
> I can buy that tab.attach may not be the best API, but in bug's comment I'm
> only reading ease of implementation motivation.

Did I mention because it's easier to implement?

Point I'm trying to make is

tab.attach(mod)
target.attach(mod)

is less natural and less ergonomic than

mod.attach(target)

It's just natural to learn about `mod` (modification) abstraction and
than apply that knowledge to all (modification) targets (anything that
wraps document).

At the moment `tab` is exception and people ask for more exceptions like
it. It's better to provide general re-usable solution that involves less
learning curve. Every new (modification) target we'll add will just
inherently work the same.

Questionable ease of implementation is just a side effect of better composable
components.
Also linked content-script JEP https://github.com/mozilla/addon-sdk/wiki/JEP-Content-scripts may be more generic solution for the problems this attempts to solve.
Blocks: 821779
Duplicate of this bug: 697590
You need to log in before you can comment on or make changes to this bug.