Closed Bug 755963 Opened 12 years ago Closed 6 years ago

Fix unfortunate design decision of tab.attach

Categories

(Add-on SDK Graveyard :: General, defect, P2)

defect

Tracking

(Not tracked)

RESOLVED INCOMPLETE
Future

People

(Reporter: irakli, Unassigned)

References

()

Details

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) ?
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.
Add-on SDK is no longer supported so resolving bugs as INCOMPLETE
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.