Skip to content

Commit a800991

Browse files
author
Justin Moore
committed
Disable safari 8 fix and promisify tabs
1 parent 09c3bf3 commit a800991

4 files changed

Lines changed: 55 additions & 6 deletions

File tree

src/mm-tab/mm-tab.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<link rel="import" href="../../bower_components/polymer/polymer.html"/>
88
<link rel="import" href="../shared/fonts/fonts.html"/>
99
<link rel="import" href="../shared/js/colors.html"/>
10+
<link rel="import" href="../shared/js/zousan.html"/>
1011
<link rel="import" href="../shared/behaviors/stylable.html"/>
1112
<link rel="import" href="../shared/behaviors/templatefindable.html"/>
1213
<link rel="import" href="../mm-template-finder/mm-template-finder.html"/>

src/mm-tab/mm-tab.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@
2828
_callback: {
2929
type: Object,
3030
},
31+
_resolved: Object,
32+
promise: {
33+
type: Object,
34+
value: function () {
35+
return new Zousan();
36+
},
37+
notify: true,
38+
readOnly: true,
39+
},
3140
},
3241

3342
behaviors: [
@@ -53,12 +62,28 @@
5362
label: this.tabLabel,
5463
target: this,
5564
});
65+
66+
if (!this.promise ||
67+
this.promise === this._resolved) {
68+
this._setPromise(new Zousan());
69+
}
70+
71+
this.promise.resolve(this._instance);
72+
73+
this.set("_resolved", this.promise);
5674
}
5775
},
5876

5977
loadExternal: function(path, callback) {
78+
if (!this.promise ||
79+
this.promise === this._resolved) {
80+
this._setPromise(new Zousan());
81+
}
82+
6083
this._callback = callback;
6184
this.set("templateFindable.templateUri", path);
85+
86+
return this.promise;
6287
},
6388

6489
});

src/mm-tabs/index.html

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,30 @@ <h4>Expanded Concept</h4>
165165
type: "swf",
166166
file: "Creative_File_" + i + ".swf",
167167
selected: false,
168-
expanded: false
168+
expanded: false,
169+
subdata: [{
170+
id: 0,
171+
name: Math.random().toString(36).substring(7),
172+
advertiser: "Advertiser No. " + 0,
173+
concept: "Concept No. " + 0,
174+
}, {
175+
id: 1,
176+
name: Math.random().toString(36).substring(7),
177+
advertiser: "Advertiser No. " + 1,
178+
concept: "Concept No. " + 1,
179+
}],
169180
});
170181
}
171182

172183
grid1.strConcat = strMaker;
173184
grid1.data = grid1Data;
174185

186+
document.querySelector("mm-tab#ext").promise.then(function (instance) {
187+
instance.$$("mm-tab#sameContent").promise.then(function (dataHost) {
188+
dataHost.set("data", grid1Data);
189+
})
190+
});
191+
175192
document.querySelector('#jsContent').loadExternal('tab-content-alt.html', function(dataHost) {
176193
var grid2Data = [];
177194

src/shared/behaviors/templatefindable.html

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,20 @@
6464
var module = document.createElement("dom-module");
6565
var template = document.createElement("template");
6666
template.innerHTML = html;
67-
var subtemplates = Array.apply(null, template.content.querySelectorAll("template:not([is])"));
68-
var exclusions = subtemplates.map(function (sub) {
67+
68+
var fix = 0|false; // for Safari 8
69+
70+
var subtemplates = !fix ?
71+
null : Array.apply(null, template.content.querySelectorAll("template:not([is])"));
72+
var exclusions = !subtemplates ? null : subtemplates.map(function (sub) {
6973
return Array.apply(null, sub.content.querySelectorAll("template:not([is])"));
7074
}).reduce(arrayConcat, []).reduce(function (reduction, sub) {
7175
if (reduction.indexOf(sub) < 0) {
7276
reduction.push(sub);
7377
}
7478
return reduction;
7579
}, []);
76-
var inclusions = subtemplates.map(function (sub) {
80+
var inclusions = !subtemplates ? null : subtemplates.map(function (sub) {
7781
return this.indexOf(sub) < 0 ? sub : null;
7882
}, exclusions);
7983

@@ -109,8 +113,10 @@
109113
document.importNode(template.content, true) :
110114
document.adoptNode(template.content.cloneNode(true));
111115

112-
// the above does not work in Safari 8 without the following
113-
Array.apply(null, dom.querySelectorAll("template")).forEach(patch, inclusions);
116+
// the above does not work in Safari 8 without the following fix applied
117+
if (inclusions) {
118+
Array.apply(null, dom.querySelectorAll("template")).forEach(patch, inclusions);
119+
}
114120

115121
return dom;
116122
},

0 commit comments

Comments
 (0)