Skip to content

Commit

Permalink
feat(polymer 3): Add polymer 3 support
Browse files Browse the repository at this point in the history
Added changes from tur-nr#99
  • Loading branch information
pixelass committed Nov 25, 2017
1 parent 4b2ff06 commit 72d884e
Show file tree
Hide file tree
Showing 7 changed files with 12,433 additions and 50 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ addons:
cache:
yarn: true

before_script:
- bower install

script:
- xvfb-run npm test

Expand Down
37 changes: 0 additions & 37 deletions bower.json

This file was deleted.

54 changes: 51 additions & 3 deletions dist/polymer-redux.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,55 @@

var console_1 = console;

window.JSCompiler_renameProperty = function (prop, obj) {
return prop;
};

function normalize(path) {
if (Array.isArray(path)) {
var parts = [];
for (var i = 0; i < path.length; i++) {
var args = path[i].toString().split('.');
for (var j = 0; j < args.length; j++) {
parts.push(args[j]);
}
}
return parts.join('.');
} else {
return path;
}
}

function split(path) {
if (Array.isArray(path)) {
return normalize(path).split('.');
}
return path.toString().split('.');
}

function get(root, path, info) {
var prop = root;
var parts = split(path);
// Loop over path parts[0..n-1] and dereference
for (var i = 0; i < parts.length; i++) {
if (!prop) {
return;
}
var part = parts[i];
prop = prop[part];
}
if (info) {
info.path = parts.join('.');
}
return prop;
}

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }

// Expose globals
var CustomEvent = window_1.CustomEvent;
var Polymer = window_1.Polymer;

/**
* Polymer Redux
Expand Down Expand Up @@ -85,7 +127,7 @@
// Perhaps .reduce() to a boolean?
var statePath = properties[name].statePath;

var value = typeof statePath === 'function' ? statePath.call(element, state) : Polymer.Path.get(state, statePath);
var value = typeof statePath === 'function' ? statePath.call(element, state) : get(state, statePath);

var changed = element._setPendingPropertyOrPath(name, value, true);
propertiesChanged = propertiesChanged || changed;
Expand All @@ -104,8 +146,9 @@
});

subscribers.set(element, unsubscribe);
update(store.getState());

return update(store.getState());
return update;
};

/**
Expand Down Expand Up @@ -225,6 +268,11 @@
});
return originalAction.apply(undefined, args);
};
// Copy props from the original action to the proxy.
// see https://github.com/tur-nr/polymer-redux/issues/98
Object.keys(originalAction).forEach(function (prop) {
action[prop] = originalAction[prop];
});

// Copy props from the original action to the proxy.
// see https://github.com/tur-nr/polymer-redux/issues/98
Expand Down
54 changes: 51 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,55 @@ var window_1 = win;

var console_1 = console;

window.JSCompiler_renameProperty = function (prop, obj) {
return prop;
};

function normalize(path) {
if (Array.isArray(path)) {
var parts = [];
for (var i = 0; i < path.length; i++) {
var args = path[i].toString().split('.');
for (var j = 0; j < args.length; j++) {
parts.push(args[j]);
}
}
return parts.join('.');
} else {
return path;
}
}

function split(path) {
if (Array.isArray(path)) {
return normalize(path).split('.');
}
return path.toString().split('.');
}

function get(root, path, info) {
var prop = root;
var parts = split(path);
// Loop over path parts[0..n-1] and dereference
for (var i = 0; i < parts.length; i++) {
if (!prop) {
return;
}
var part = parts[i];
prop = prop[part];
}
if (info) {
info.path = parts.join('.');
}
return prop;
}

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }

// Expose globals
var CustomEvent = window_1.CustomEvent;
var Polymer = window_1.Polymer;

/**
* Polymer Redux
Expand Down Expand Up @@ -85,7 +127,7 @@ function PolymerRedux(store) {
// Perhaps .reduce() to a boolean?
var statePath = properties[name].statePath;

var value = typeof statePath === 'function' ? statePath.call(element, state) : Polymer.Path.get(state, statePath);
var value = typeof statePath === 'function' ? statePath.call(element, state) : get(state, statePath);

var changed = element._setPendingPropertyOrPath(name, value, true);
propertiesChanged = propertiesChanged || changed;
Expand All @@ -104,8 +146,9 @@ function PolymerRedux(store) {
});

subscribers.set(element, unsubscribe);
update(store.getState());

return update(store.getState());
return update;
};

/**
Expand Down Expand Up @@ -225,6 +268,11 @@ function PolymerRedux(store) {
});
return originalAction.apply(undefined, args);
};
// Copy props from the original action to the proxy.
// see https://github.com/tur-nr/polymer-redux/issues/98
Object.keys(originalAction).forEach(function (prop) {
action[prop] = originalAction[prop];
});

// Copy props from the original action to the proxy.
// see https://github.com/tur-nr/polymer-redux/issues/98
Expand Down
Loading

0 comments on commit 72d884e

Please sign in to comment.