I just realized that Drupal.theme is never used as a constructor to make an object but is always used as a typical object.
Drupal.theme will explicitly look for a default implementation in the prototype object, for all intent and purpose we could be using mickey instead of prototype.
And better, just remove the extra object altogether and just implement Drupal.theme.myThemeFunction. I'm not aware of a module needing to override a JS theme function and still access the default implementation.
// Before
Drupal.theme.prototype.myThemeFunction = function () {};
// After
Drupal.theme.myThemeFunction = function () {};
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | core-js-remove-theme-prototype-1630782-2.patch | 5.25 KB | nod_ |
Comments
Comment #1
nod_Comment #2
nod_not really a bug, just something dirty.
This patch remove
prototypealtogether and doesn't replace it withdefaulteither. The code is as straightforward as it's supposed to be.Comment #2.0
nod_syntax
Comment #3
lomo commentedEverything seems to work as expected after applying the patch and there are no references to theme.prototype anymore, anywhere in core, now, so I would say this can be considered RTBC.
Comment #4
webchickAwesome, thanks for the functional review! I think this could still use code review though.
Comment #5
webchickOk, nod_ sat down and spent the better part of a half hour on teaching me JS so I could understand this patch. ;) Basically we don't need Drupal.theme.prototype, because Drupal.theme is already an object. Or something like that. ;)
Committed and pushed to 8.x. Thanks!
Comment #6
nod_Follow-up #1740958: overlay is broken
Comment #8
nod_As WimLeers pointed out, this needs a change notice: http://drupal.org/node/1816980. Marking back as fixed in case someone missed it.
Comment #9.0
(not verified) commentedcorrect example