1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-24 06:52:28 +01:00

ES6-ify some things. Still a long way to go...

This commit is contained in:
Kris Maglione
2015-12-20 02:02:54 -08:00
parent 65725c9516
commit 27cdeb1885
28 changed files with 411 additions and 303 deletions

View File

@@ -58,8 +58,8 @@ var Buffer = Module("Buffer", {
* buffer. Only returns style sheets for the 'screen' media type.
*/
get alternateStyleSheets() {
let stylesheets = Ary.flatten(
this.allFrames().map(w => Array.slice(w.document.styleSheets)));
let stylesheets = this.allFrames()
.flatMap(w => w.document.styleSheets);
return stylesheets.filter(
s => /^(screen|all|)$/i.test(s.media.mediaText) && !/^\s*$/.test(s.title)
@@ -415,11 +415,12 @@ var Buffer = Module("Buffer", {
* Returns a list of all frames in the given window or current buffer.
*/
allFrames: function allFrames(win=this.win, focusedFirst) {
let frames = iter(util.iterFrames(win)).toArray();
let frames = Array.from(util.iterFrames(win));
if (focusedFirst)
return frames.filter(f => f === this.focusedFrame).concat(
frames.filter(f => f !== this.focusedFrame));
if (focusedFirst) {
let focused = this.focusedFrame;
return frames.sort((a, b) => (b === focused) - (a === focused));
}
return frames;
},
@@ -2415,8 +2416,10 @@ var Buffer = Module("Buffer", {
let frames = buffer.allFrames(undefined, true);
let elements = Ary.flatten(frames.map(win => [m for (m of DOM.XPath(xpath, win.document))]))
.filter(function (elem) {
let elements = Array.from(frames)
.flatMap(win => DOM.XPath(xpath, win.document))
.filter(elem => {
if (isinstance(elem, [Ci.nsIDOMHTMLFrameElement,
Ci.nsIDOMHTMLIFrameElement]))
return Editor.getEditor(elem.contentWindow);
@@ -2428,9 +2431,11 @@ var Buffer = Module("Buffer", {
let style = elem.style;
let rect = elem.rect;
return elem.isVisible &&
(elem[0] instanceof Ci.nsIDOMXULTextBoxElement || style.MozUserFocus != "ignore") &&
rect.width && rect.height;
(elem[0] instanceof Ci.nsIDOMXULTextBoxElement ||
style.MozUserFocus != "ignore") &&
rect.width && rect.height;
});
dactyl.assert(elements.length > 0);