Skip to content

Commit

Permalink
Update to Polymer 1.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Download committed Nov 28, 2015
1 parent 1dc7075 commit bfc3ba2
Show file tree
Hide file tree
Showing 1,778 changed files with 83,338 additions and 13,541 deletions.
695 changes: 477 additions & 218 deletions README.md

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polymer-cdn",
"version": "1.0.0",
"version": "1.2.3",
"main": "polymer.js",
"homepage": "https://github.com/Download/polymer-cdn",
"authors": [
Expand All @@ -21,8 +21,8 @@
"tests"
],
"dependencies": {
"polymer": "Polymer/polymer#1.0.0",
"paper-elements": "polymerelements/paper-elements#~1.0.1",
"polymer": "Polymer/polymer#1.2.3",
"paper-elements": "polymerelements/paper-elements#~1.0.6",
"iron-elements": "polymerelements/iron-elements#~1.0.2",
"neon-elements": "polymerelements/neon-elements#~1.0.0",
"gold-elements": "polymerelements/gold-elements#~1.0.1",
Expand All @@ -31,6 +31,6 @@
"molecules": "polymerelements/molecules#~1.0.0"
},
"resolutions": {
"polymer": "^1.1.4"
"polymer": "^1.2.3"
}
}
4 changes: 2 additions & 2 deletions lib/cors-upload-sample/.bower.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "cors-upload-sample",
"homepage": "https://github.com/googledrive/cors-upload-sample",
"_release": "a8c9d0b144",
"_release": "37c97848a2",
"_resolution": {
"type": "branch",
"branch": "master",
"commit": "a8c9d0b144fde34d414ee80c2e70dd312c8aa8b3"
"commit": "37c97848a239d2bbaccbe4eecb27b6119cc473ff"
},
"_source": "git://github.com/googledrive/cors-upload-sample.git",
"_target": "master",
Expand Down
2 changes: 2 additions & 0 deletions lib/cors-upload-sample/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ MediaUploader.prototype.onContentUploadSuccess_ = function(e) {
this.extractRange_(e.target);
this.retryHandler.reset();
this.sendFile_();
} else {
this.onContentUploadError_(e);
}
};

Expand Down
8 changes: 4 additions & 4 deletions lib/firebase-element/.bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "firebase-element",
"description": "An element that makes it easy to declaratively use the powerful firebase backend",
"version": "1.0.6",
"version": "1.0.8",
"private": true,
"main": [
"firebase-collection.html",
Expand All @@ -22,11 +22,11 @@
"web-component-tester": "*"
},
"homepage": "https://github.com/GoogleWebComponents/firebase-element",
"_release": "1.0.6",
"_release": "1.0.8",
"_resolution": {
"type": "version",
"tag": "v1.0.6",
"commit": "e0526a5a62c41b074e41ab3b0a0d21fb0b43ded0"
"tag": "v1.0.8",
"commit": "a9946abca531208401e24004a6ad5b6fda42c679"
},
"_source": "git://github.com/GoogleWebComponents/firebase-element.git",
"_target": "^1.0.0",
Expand Down
28 changes: 28 additions & 0 deletions lib/firebase-element/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
language: node_js
sudo: false
matrix:
include:
- node_js: stable
script: xvfb-run -a wct --simpleOutput -l firefox -l chrome
addons:
firefox: latest
apt:
sources:
- google-chrome
packages:
- google-chrome-stable
- node_js: node
script:
- |
if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then
wct --simpleOutput -s 'Windows 10/microsoftedge' -s 'Windows 8.1/internet explorer@11' -s 'Windows 7/internet explorer@10' -s 'OS X 10.10/safari@8' -s 'OS X 10.9/safari@7'
fi
before_script:
- npm install bower
- npm install web-component-tester
- export PATH=$PWD/node_modules/.bin:$PATH
- bower install
env:
global:
- secure: dlr2l5btcMEnaJI/VzBDIKhcJTUgnrQ6AN/S+qbPFqsckokV5SCt3k0f0Z22CBhBXJi2qVrLDX05+wZ4FkVkLLdGOf6zR0sSNvXubzvUu8oKaZczo2B8EAs+OjsuvaZWPYTabAOGvyAwuBzfZaYDlXbk6Dlb/51hjzSl2D5/WbY=
- secure: dFreaGtRTAwcFtSZ57ktyiDejTkJ7vI9TVbJZ0Yd9Adp/4mINOOgHDFiVDl5kDCy9xx21vCRel+IrGkOdRllk+OWxO8Ga1OQF4EzchvUsxzngDwi3I0P1+uNuzjn8MyEvE4HYPwDZ0mDYzMLJS9b1GlcpMTvJvE2Sg3ly8h4wYc=
2 changes: 1 addition & 1 deletion lib/firebase-element/bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "firebase-element",
"description": "An element that makes it easy to declaratively use the powerful firebase backend",
"version": "1.0.6",
"version": "1.0.8",
"private": true,
"main": ["firebase-collection.html","firebase-document.html","firebase-auth.html","firebase-query-behavior.html"],
"dependencies": {
Expand Down
10 changes: 6 additions & 4 deletions lib/firebase-element/firebase-auth.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

<!--
Element wrapper for the Firebase authentication API (https://www.firebase.com/docs/web/guide/user-auth.html).
@demo demo/index.html
-->

<script>
Expand Down Expand Up @@ -198,8 +200,8 @@
* is restored.
*
* @method login
* @param {string} params (optional)
* @param {string} options (optional)
* @param {Object} params (optional)
* @param {Object} options (optional)
*/
login: function(params, options) {
if (!this.ref || navigator.onLine === false) {
Expand Down Expand Up @@ -236,9 +238,9 @@
/**
* Performs a logout attempt.
*
* If the login is successful, the `logout` event is fired.
* If the logout is successful, the `logout` event is fired.
*
* If login fails, the `error` event is fired, with `e.detail` containing error
* If logout fails, the `error` event is fired, with `e.detail` containing error
* information supplied from Firebase.
*
* If the browswer supports `navigator.onLine` network status reporting and the
Expand Down
132 changes: 108 additions & 24 deletions lib/firebase-element/firebase-collection.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ <h4>[[dinosaur.__firebaseKey__]]</h4>
Accessor methods such as `add` and `remove` are provided to enable convenient
manipulation of the collection without direct knowledge of Firebase key values.
@demo demo/index.html
-->

<script>
Expand Down Expand Up @@ -233,6 +235,11 @@ <h4>[[dinosaur.__firebaseKey__]]</h4>
'firebase-child-moved': '_onFirebaseChildMoved',
},

created: function() {
this._pendingSplices = [];
this._lastLocallyAddedIndex = null;
},

/**
* Add an item to the document referenced at `location`. A key associated
* with the item will be created by Firebase, and can be accessed via the
Expand Down Expand Up @@ -261,7 +268,10 @@ <h4>[[dinosaur.__firebaseKey__]]</h4>
*/
remove: function(data) {
if (data == null || data.__firebaseKey__ == null) {
this._error('Failed to remove unknown value:', data);
// NOTE(cdata): This might be better as an error message in the
// console, but `Polymer.Base._error` throws, which we don't want
// to happen in this case.
this._warn('Refusing to remove unknown value:', data);
return;
}

Expand All @@ -287,49 +297,82 @@ <h4>[[dinosaur.__firebaseKey__]]</h4>
* located at `location`.
*/
removeByKey: function(key) {
if (!this.query) {
this._error('Cannot remove items before query has been initialized.');
return;
}

this.query.ref().child(key).remove();
},

_applyLocalDataChanges: function(change) {
_localDataChanged: function(change) {
var pathParts = change.path.split('.');
var firebaseKey;
var key;
var value;

// We don't care about self-changes, and we don't respond directly to
// length changes:
if (pathParts.length < 2 || pathParts[1] === 'length') {
return;
}

if (pathParts[1] === 'splices') {
this._applySplicesToRemoteData(change.value.indexSplices);
// Handle splices via the adoption process. `indexSplices` is known to
// sometimes be null, so guard against that.
if (pathParts[1] === 'splices' && change.value.indexSplices != null) {
this._adoptSplices(change.value.indexSplices);
return;
}

key = pathParts[1];
value = Polymer.Collection.get(change.base).getItem(key);
// Otherwise, the change is happening to a sub-path of the array.
this._applySubPathChange(change);
},

// Temporarily remove the client-only `__firebaseKey__` property:
firebaseKey = value.__firebaseKey__;
value.__firebaseKey__ = null;
_applySubPathChange: function(change) {
var key = change.path.split('.')[1];
var value = Polymer.Collection.get(change.base).getItem(key);
var firebaseKey = value.__firebaseKey__;

// We don't want to accidentally reflect `__firebaseKey__` in the
// remote data, so we remove it temporarily. `null` values will be
// discarded by Firebase, so `delete` is not necessary:
value.__firebaseKey__ = null;
this.query.ref().child(firebaseKey).set(value);

value.__firebaseKey__ = firebaseKey;
},

_applySplicesToRemoteData: function(splices) {
this._log('splices', splices);
splices.forEach(function(splice) {
var added = splice.object.slice(splice.index, splice.index + splice.addedCount);
_adoptSplices: function(splices) {
this._pendingSplices = this._pendingSplices.concat(splices);

splice.removed.forEach(function(removed) {
this.remove(removed);
// We can afford apply removals synchronously, so we do that first
// and save the `added` operations for the `debounce` below.
this._applyLocalDataChange(function() {
splices.forEach(function(splice) {
splice.removed.forEach(function(removed) {
this.remove(removed);
}, this);
}, this);
});

added.forEach(function(added) {
this.add(added);
}, this);
}, this);
// We async until the next turn. The reason we want to do this is
// that splicing within a splice handler will break the data binding
// system in some places. This is referred to as the "re-entrancy"
// problem. See polymer/polymer#2491.
this.debounce('_adoptSplices', function() {
this._applyLocalDataChange(function() {
var splices = this._pendingSplices;

this._pendingSplices = [];

splices.forEach(function(splice) {
var added = splice.object.slice(splice.index, splice.index + splice.addedCount);

added.forEach(function(added, index) {
this._lastLocallyAddedIndex = splice.index + index;
this.add(added);
}, this);
}, this);

this._lastLocallyAddedIndex = null;
});
});
},

_computeQuery: function(location, limitToFirst, limitToLast, orderByMethodName, startAt, endAt, equalTo) {
Expand All @@ -339,6 +382,8 @@ <h4>[[dinosaur.__firebaseKey__]]</h4>
return;
}

this._log('Recomputing query.', arguments);

query = new Firebase(location);

if (orderByMethodName) {
Expand Down Expand Up @@ -460,17 +505,56 @@ <h4>[[dinosaur.__firebaseKey__]]</h4>
_onFirebaseChildAdded: function(event) {
this._applyRemoteDataChange(function() {
var value = this._valueFromSnapshot(event.detail.childSnapshot);
var key = value.__firebaseKey__;
var previousValueKey = event.detail.previousChildName;
var index = previousValueKey != null ?
this.data.indexOf(this._valueMap[previousValueKey]) + 1 : 0;
var lastLocallyAddedValue;

this._valueMap[value.__firebaseKey__] = value;

this.splice('data', index, 0, value);
// NOTE(cdata): The rationale for this conditional dance around the
// last locally added index (since you will inevitably be wondering
// why we do it):
// There may be a "locally" added value which was spliced in. If
// there is, it may be in the "wrong" place in the array. This is
// due to the fact that Firebase may be applying a sort to the
// data, so we won't know the correct index for the locally added
// value until the `child_added` event is fired.
// Once we get the `child_added` event, we can check to see if the
// locally added value is in the right place. If it is, we just
// `set` it to the Firebase-provided value. If it is not, then
// we grab the original value, splice in the Firebase-provided
// value in the right place, and then (importantly: at the end)
// find the locally-added value again (since its index may have
// changed by splicing-in Firebase's value) and splice it out of the
// array.
if (this._lastLocallyAddedIndex === index) {
this.set(['data', index], value);
} else {
if (this._lastLocallyAddedIndex != null) {
lastLocallyAddedValue = this.data[this._lastLocallyAddedIndex];
}

this.splice('data', index, 0, value);

if (this._lastLocallyAddedIndex != null) {
this.splice('data', this.data.indexOf(lastLocallyAddedValue), 1);
}
}
});
},

_onFirebaseChildRemoved: function(event) {
if (this._receivingLocalChanges) {
this._valueMap[event.detail.oldChildSnapshot.key()] = null;
// NOTE(cdata): If we are receiving local changes, that means that
// the splices have already been performed and items are already
// removed from the local data representation. No need to remove
// them again.
return;
}

this._applyRemoteDataChange(function() {
var key = event.detail.oldChildSnapshot.key();
var value = this._valueMap[key];
Expand Down
10 changes: 7 additions & 3 deletions lib/firebase-element/firebase-document.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
Polymer's data-binding system, changes to the document will be automatically
reflected in the remote document and any other clients referencing that
document.
@demo demo/index.html
-->

<script>
Expand Down Expand Up @@ -64,7 +66,7 @@
'firebase-value': '_onFirebaseValue'
},

_applyLocalDataChanges: function(change) {
_localDataChanged: function(change) {
var pathFragments = change.path.split('.');

if (pathFragments.length === 1) {
Expand Down Expand Up @@ -98,8 +100,10 @@
},

_setRemoteDocumentChild: function(key, value) {
this._log('Setting child "' + key + '" to', value);
this.query.child(key).set(value);
this.debounce('set-' + key, function() {
this._log('Setting child "' + key + '" to', value);
this.query.child(key).set(value);
});
},

_removeRemoteDocumentChild: function(key) {
Expand Down
Loading

0 comments on commit bfc3ba2

Please sign in to comment.