mirror of
https://github.com/discourse/discourse.git
synced 2025-04-03 05:39:41 +08:00
DEV: Remove buffered-render file
This is the last and final commit in a multi-commit refactor to remove all uses of buffered-render. Previous commit: fc94b6cb9ee709a6744dc0da477f4a37e43d37e4 in this series.
This commit is contained in:
parent
648a1124eb
commit
1a31a403ce
@ -1,46 +0,0 @@
|
|||||||
import { scheduleOnce } from "@ember/runloop";
|
|
||||||
// Ember 2.0 removes buffered rendering, but we can still implement it ourselves.
|
|
||||||
// In the long term we'll want to remove this.
|
|
||||||
|
|
||||||
const Mixin = {
|
|
||||||
_customRender() {
|
|
||||||
if (!this.element || this.isDestroying || this.isDestroyed) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const buffer = [];
|
|
||||||
this.buildBuffer(buffer);
|
|
||||||
this.element.innerHTML = buffer.join("");
|
|
||||||
},
|
|
||||||
|
|
||||||
rerenderBuffer() {
|
|
||||||
scheduleOnce("render", this, this._customRender);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export function bufferedRender(obj) {
|
|
||||||
if (!obj.buildBuffer) {
|
|
||||||
Ember.warn("Missing `buildBuffer` method", {
|
|
||||||
id: "discourse.buffered-render.missing-build-buffer"
|
|
||||||
});
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
const caller = {};
|
|
||||||
|
|
||||||
caller.didRender = function() {
|
|
||||||
this._super(...arguments);
|
|
||||||
this._customRender();
|
|
||||||
};
|
|
||||||
|
|
||||||
const triggers = obj.rerenderTriggers;
|
|
||||||
if (triggers) {
|
|
||||||
caller.init = function() {
|
|
||||||
this._super(...arguments);
|
|
||||||
triggers.forEach(k => this.addObserver(k, this.rerenderBuffer));
|
|
||||||
};
|
|
||||||
}
|
|
||||||
delete obj.rerenderTriggers;
|
|
||||||
|
|
||||||
return Ember.Mixin.create(Mixin, caller, obj);
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user