Skip to content

Commit

Permalink
Updated polymer to v1.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
alchaplinsky committed Feb 12, 2016
1 parent c7c2f91 commit 9e8932a
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 47 deletions.
51 changes: 33 additions & 18 deletions app/assets/javascripts/polymer/polymer-micro.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,30 +127,40 @@
_afterNextRenderQueue: [],
_waitingNextRender: false,
afterNextRender: function (element, fn, args) {
if (!this._waitingNextRender) {
this._waitingNextRender = true;
this.whenReady(this._flushAfterNextRender);
}
this._watchNextRender();
this._afterNextRenderQueue.push([
element,
fn,
args
]);
},
_flushAfterNextRender: function () {
requestAnimationFrame(function () {
setTimeout(Polymer.RenderStatus.__flushAfterNextRender);
});
_watchNextRender: function () {
if (!this._waitingNextRender) {
this._waitingNextRender = true;
var fn = function () {
Polymer.RenderStatus._flushNextRender();
};
if (!this._ready) {
this.whenReady(fn);
} else {
requestAnimationFrame(fn);
}
}
},
__flushAfterNextRender: function () {
var self = Polymer.RenderStatus;
_flushNextRender: function () {
var self = this;
setTimeout(function () {
self._flushRenderCallbacks(self._afterNextRenderQueue);
self._afterNextRenderQueue = [];
self._waitingNextRender = false;
for (var i = 0, h; i < self._afterNextRenderQueue.length; i++) {
h = self._afterNextRenderQueue[i];
});
},
_flushRenderCallbacks: function (callbacks) {
for (var i = 0, h; i < callbacks.length; i++) {
h = callbacks[i];
h[1].apply(h[0], h[2] || Polymer.nar);
}
;
self._afterNextRenderQueue = [];
}
};
if (window.HTMLImports) {
Expand Down Expand Up @@ -284,7 +294,7 @@
if (id) {
var m = findModule(id);
if (!m) {
forceDocumentUpgrade();
forceDomModulesUpgrade();
m = findModule(id);
}
if (m && selector) {
Expand All @@ -296,12 +306,17 @@
});
var cePolyfill = window.CustomElements && !CustomElements.useNative;
document.registerElement('dom-module', DomModule);
function forceDocumentUpgrade() {
function forceDomModulesUpgrade() {
if (cePolyfill) {
var script = document._currentScript || document.currentScript;
var doc = script && script.ownerDocument || document;
if (doc) {
CustomElements.upgradeAll(doc);
var modules = doc.querySelectorAll('dom-module');
for (var i = modules.length - 1, m; i >= 0 && (m = modules[i]); i--) {
if (m.__upgraded__) {
return;
} else {
CustomElements.upgrade(m);
}
}
}
}
Expand Down Expand Up @@ -661,7 +676,7 @@
}
}
});
Polymer.version = '1.2.2';
Polymer.version = '1.2.3';
Polymer.Base._addFeature({
_registerFeatures: function () {
this._prepIs();
Expand Down
3 changes: 1 addition & 2 deletions app/assets/javascripts/polymer/polymer-mini.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
if (this._template && this._template.hasAttribute('is')) {
this._warn(this._logf('_prepTemplate', 'top-level Polymer template ' + 'must not be a type-extension, found', this._template, 'Move inside simple <template>.'));
}
if (this._template && !this._template.content && HTMLTemplateElement.bootstrap) {
if (this._template && !this._template.content && window.HTMLTemplateElement && HTMLTemplateElement.decorate) {
HTMLTemplateElement.decorate(this._template);
HTMLTemplateElement.bootstrap(this._template.content);
}
},
_stampTemplate: function () {
Expand Down
20 changes: 16 additions & 4 deletions app/assets/javascripts/polymer/polymer.html
Original file line number Diff line number Diff line change
Expand Up @@ -3527,19 +3527,19 @@
var e = this.__appliedElement || this;
styleDefaults.addStyle(e);
if (e.textContent || this.include) {
this._apply();
this._apply(true);
} else {
var self = this;
var observer = new MutationObserver(function () {
observer.disconnect();
self._apply();
self._apply(true);
});
observer.observe(e, { childList: true });
}
}
}
},
_apply: function () {
_apply: function (deferProperties) {
var e = this.__appliedElement || this;
if (this.include) {
e.textContent = styleUtil.cssFromModules(this.include, true) + e.textContent;
Expand All @@ -3548,7 +3548,19 @@
styleUtil.forEachStyleRule(styleUtil.rulesForStyle(e), function (rule) {
styleTransformer.documentRule(rule);
});
this._applyCustomProperties(e);
var self = this;
function fn() {
self._applyCustomProperties(e);
}
if (this._pendingApplyProperties) {
cancelAnimationFrame(this._pendingApplyProperties);
this._pendingApplyProperties = null;
}
if (deferProperties) {
this._pendingApplyProperties = requestAnimationFrame(fn);
} else {
fn();
}
}
},
_applyCustomProperties: function (element) {
Expand Down
25 changes: 14 additions & 11 deletions app/assets/javascripts/webcomponentsjs/webcomponents-lite.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
// @version 0.7.17
// @version 0.7.20
(function() {
window.WebComponents = window.WebComponents || {
flags: {}
Expand Down Expand Up @@ -920,9 +920,10 @@ if (typeof HTMLTemplateElement === "undefined") {
HTMLTemplateElement = function() {};
HTMLTemplateElement.prototype = Object.create(HTMLElement.prototype);
HTMLTemplateElement.decorate = function(template) {
if (!template.content) {
template.content = contentDoc.createDocumentFragment();
if (template.content) {
return;
}
template.content = contentDoc.createDocumentFragment();
var child;
while (child = template.firstChild) {
template.content.appendChild(child);
Expand Down Expand Up @@ -953,6 +954,7 @@ if (typeof HTMLTemplateElement === "undefined") {
canDecorate = false;
}
}
HTMLTemplateElement.bootstrap(template.content);
};
HTMLTemplateElement.bootstrap = function(doc) {
var templates = doc.querySelectorAll(TEMPLATE_TAG);
Expand Down Expand Up @@ -1039,7 +1041,8 @@ if (typeof HTMLTemplateElement === "undefined") {
Object.defineProperty(this, "defaultPrevented", {
get: function() {
return true;
}
},
configurable: true
});
};
}
Expand Down Expand Up @@ -1140,6 +1143,7 @@ window.HTMLImports = window.HTMLImports || {
if (importCount) {
for (var i = 0, imp; i < importCount && (imp = imports[i]); i++) {
if (isImportLoaded(imp)) {
newImports.push(this);
parsedCount++;
checkDone();
} else {
Expand Down Expand Up @@ -2057,24 +2061,23 @@ window.CustomElements.addModule(function(scope) {
return root;
};
}
function upgradeAll(doc) {
if (HTMLTemplateElement && HTMLTemplateElement.bootstrap) {
HTMLTemplateElement.bootstrap(doc);
}
addedNode(doc);
}
scope.watchShadow = watchShadow;
scope.upgradeDocumentTree = upgradeDocumentTree;
scope.upgradeDocument = upgradeDocument;
scope.upgradeSubtree = addedSubtree;
scope.upgradeAll = upgradeAll;
scope.upgradeAll = addedNode;
scope.attached = attached;
scope.takeRecords = takeRecords;
});

window.CustomElements.addModule(function(scope) {
var flags = scope.flags;
function upgrade(node, isAttached) {
if (node.localName === "template") {
if (window.HTMLTemplateElement && HTMLTemplateElement.decorate) {
HTMLTemplateElement.decorate(node);
}
}
if (!node.__upgraded__ && node.nodeType === Node.ELEMENT_NODE) {
var is = node.getAttribute("is");
var definition = scope.getRegisteredDefinition(node.localName) || scope.getRegisteredDefinition(is);
Expand Down
67 changes: 56 additions & 11 deletions app/assets/javascripts/webcomponentsjs/webcomponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
// @version 0.7.17
// @version 0.7.20
(function() {
window.WebComponents = window.WebComponents || {
flags: {}
Expand Down Expand Up @@ -352,6 +352,7 @@ if (WebComponents.flags.shadow) {
});
});
}
scope.addForwardingProperties = addForwardingProperties;
scope.assert = assert;
scope.constructorTable = constructorTable;
scope.defineGetter = defineGetter;
Expand Down Expand Up @@ -1172,7 +1173,8 @@ if (WebComponents.flags.shadow) {
Object.defineProperty(this, "defaultPrevented", {
get: function() {
return true;
}
},
configurable: true
});
};
}
Expand Down Expand Up @@ -2770,7 +2772,7 @@ if (WebComponents.flags.shadow) {
enumerable: true
});
}
[ "getBoundingClientRect", "getClientRects", "scrollIntoView" ].forEach(methodRequiresRendering);
[ "focus", "getBoundingClientRect", "getClientRects", "scrollIntoView" ].forEach(methodRequiresRendering);
registerWrapper(OriginalHTMLElement, HTMLElement, document.createElement("b"));
scope.wrappers.HTMLElement = HTMLElement;
scope.getInnerHTML = getInnerHTML;
Expand Down Expand Up @@ -3305,6 +3307,7 @@ if (WebComponents.flags.shadow) {
})(window.ShadowDOMPolyfill);
(function(scope) {
"use strict";
var addForwardingProperties = scope.addForwardingProperties;
var mixin = scope.mixin;
var registerWrapper = scope.registerWrapper;
var setWrapper = scope.setWrapper;
Expand All @@ -3329,6 +3332,10 @@ if (WebComponents.flags.shadow) {
unsafeUnwrap(this).texSubImage2D.apply(unsafeUnwrap(this), arguments);
}
});
var OriginalWebGLRenderingContextBase = Object.getPrototypeOf(OriginalWebGLRenderingContext.prototype);
if (OriginalWebGLRenderingContextBase !== Object.prototype) {
addForwardingProperties(OriginalWebGLRenderingContextBase, WebGLRenderingContext.prototype);
}
var instanceProperties = /WebKit/.test(navigator.userAgent) ? {
drawingBufferHeight: null,
drawingBufferWidth: null
Expand Down Expand Up @@ -3372,6 +3379,7 @@ if (WebComponents.flags.shadow) {
var setInnerHTML = scope.setInnerHTML;
var unsafeUnwrap = scope.unsafeUnwrap;
var unwrap = scope.unwrap;
var wrap = scope.wrap;
var shadowHostTable = new WeakMap();
var nextOlderShadowTreeTable = new WeakMap();
function ShadowRoot(hostWrapper) {
Expand Down Expand Up @@ -3407,6 +3415,25 @@ if (WebComponents.flags.shadow) {
},
getSelection: function() {
return document.getSelection();
},
get activeElement() {
var unwrappedActiveElement = unwrap(this).ownerDocument.activeElement;
if (!unwrappedActiveElement || !unwrappedActiveElement.nodeType) return null;
var activeElement = wrap(unwrappedActiveElement);
if (activeElement === this.host) {
return null;
}
while (!this.contains(activeElement) && !this.host.contains(activeElement)) {
while (activeElement.parentNode) {
activeElement = activeElement.parentNode;
}
if (activeElement.host) {
activeElement = activeElement.host;
} else {
return null;
}
}
return activeElement;
}
});
scope.wrappers.ShadowRoot = ShadowRoot;
Expand Down Expand Up @@ -4065,6 +4092,7 @@ if (WebComponents.flags.shadow) {
var ShadowRoot = scope.wrappers.ShadowRoot;
var TreeScope = scope.TreeScope;
var cloneNode = scope.cloneNode;
var defineGetter = scope.defineGetter;
var defineWrapGetter = scope.defineWrapGetter;
var elementFromPoint = scope.elementFromPoint;
var forwardMethodsToWrapper = scope.forwardMethodsToWrapper;
Expand All @@ -4088,6 +4116,22 @@ if (WebComponents.flags.shadow) {
defineWrapGetter(Document, "documentElement");
defineWrapGetter(Document, "body");
defineWrapGetter(Document, "head");
defineGetter(Document, "activeElement", function() {
var unwrappedActiveElement = unwrap(this).activeElement;
if (!unwrappedActiveElement || !unwrappedActiveElement.nodeType) return null;
var activeElement = wrap(unwrappedActiveElement);
while (!this.contains(activeElement)) {
while (activeElement.parentNode) {
activeElement = activeElement.parentNode;
}
if (activeElement.host) {
activeElement = activeElement.host;
} else {
return null;
}
}
return activeElement;
});
function wrapMethod(name) {
var original = document[name];
Document.prototype[name] = function() {
Expand Down Expand Up @@ -5770,7 +5814,8 @@ if (WebComponents.flags.shadow) {
Object.defineProperty(this, "defaultPrevented", {
get: function() {
return true;
}
},
configurable: true
});
};
}
Expand Down Expand Up @@ -5871,6 +5916,7 @@ window.HTMLImports = window.HTMLImports || {
if (importCount) {
for (var i = 0, imp; i < importCount && (imp = imports[i]); i++) {
if (isImportLoaded(imp)) {
newImports.push(this);
parsedCount++;
checkDone();
} else {
Expand Down Expand Up @@ -6788,24 +6834,23 @@ window.CustomElements.addModule(function(scope) {
return root;
};
}
function upgradeAll(doc) {
if (HTMLTemplateElement && HTMLTemplateElement.bootstrap) {
HTMLTemplateElement.bootstrap(doc);
}
addedNode(doc);
}
scope.watchShadow = watchShadow;
scope.upgradeDocumentTree = upgradeDocumentTree;
scope.upgradeDocument = upgradeDocument;
scope.upgradeSubtree = addedSubtree;
scope.upgradeAll = upgradeAll;
scope.upgradeAll = addedNode;
scope.attached = attached;
scope.takeRecords = takeRecords;
});

window.CustomElements.addModule(function(scope) {
var flags = scope.flags;
function upgrade(node, isAttached) {
if (node.localName === "template") {
if (window.HTMLTemplateElement && HTMLTemplateElement.decorate) {
HTMLTemplateElement.decorate(node);
}
}
if (!node.__upgraded__ && node.nodeType === Node.ELEMENT_NODE) {
var is = node.getAttribute("is");
var definition = scope.getRegisteredDefinition(node.localName) || scope.getRegisteredDefinition(is);
Expand Down
Loading

0 comments on commit 9e8932a

Please sign in to comment.