Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adapted to work with Polymer 3.0 #99

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

35 changes: 33 additions & 2 deletions dist/polymer-redux.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,38 @@

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('.');
}

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 +110,7 @@
statePath = _properties$name.statePath,
readOnly = _properties$name.readOnly;

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

if (readOnly) {
element._setProperty(name, value);
Expand Down Expand Up @@ -225,6 +250,12 @@
});
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];
});
}

return store.dispatch(action);
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>polymer-redux</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="../webcomponentsjs/webcomponents-lite.js"></script>
<script src="./node_modules/@webcomponents/webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../iron-component-page/iron-component-page.html">
</head>
<body>
Expand Down
37 changes: 35 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Element as PolymerElement } from '../../@polymer/polymer/polymer-element';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong. lib/index.js is generated from npm run build.
Also why are you including this here when we don't use PolymerElement anywhere?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should maybe document this on the README actually of how to build the repo.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't know that... ok maybe it's better if I leave the repo adaptation to v3 to you, the main thing that is required to make polymer-redux working in a v3 project was that

import {get} from '../../@polymer/polymer/lib/utils/path';

thing, so in the meanwhile I can work with my fork.
Sorry for the inconvenience

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, don't be sorry. I'm snowed under at work, this is great I really appreciated it 👍

Just run npm run build then commit the changes and you're done 🎉


var PolymerRedux = (function () {
'use strict';

Expand All @@ -19,13 +21,38 @@ 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('.');
}

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 +112,7 @@ function PolymerRedux(store) {
statePath = _properties$name.statePath,
readOnly = _properties$name.readOnly;

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

if (readOnly) {
element._setProperty(name, value);
Expand Down Expand Up @@ -225,6 +252,12 @@ 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];
});
}

return store.dispatch(action);
Expand Down
36 changes: 34 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polymer-redux",
"version": "1.0.2",
"version": "1.0.3",
"description": "Polymer bindings for Redux.",
"main": "lib/polymer-redux.js",
"module": "src/index.js",
Expand Down Expand Up @@ -29,16 +29,17 @@
},
"homepage": "https://github.com/tur-nr/polymer-redux#readme",
"dependencies": {
"@polymer/polymer": "next",
"global": "^4.3.1"
},
"devDependencies": {
"@polymer/iron-demo-helpers": "next",
"babel-jest": "^19.0.0",
"babel-plugin-external-helpers": "^6.8.0",
"babel-plugin-transform-object-assign": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-preset-env": "^1.2.2",
"babel-register": "^6.24.0",
"bower": "^1.5.2",
"coveralls": "^2.11.9",
"del": "^2.2.2",
"gulp": "^3.9.1",
Expand All @@ -54,6 +55,7 @@
"rollup-plugin-commonjs": "^8.0.2",
"rollup-plugin-node-resolve": "^2.0.0",
"run-sequence": "^1.2.2",
"web-component-tester": "^6.1.5",
"xo": "^0.18.0"
},
"xo": {
Expand Down Expand Up @@ -104,5 +106,35 @@
"**/test/?(*.)spec.js"
],
"verbose": true
},
"dependencies": {
"@polymer/polymer": "^3.0.0-pre.1",
"global": "^4.3.1"
},
"devDependencies": {
"@polymer/iron-demo-helpers": "^0.0.3",
"babel-jest": "^19.0.0",
"babel-plugin-external-helpers": "^6.8.0",
"babel-plugin-transform-object-assign": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-preset-env": "^1.2.2",
"babel-register": "^6.24.0",
"coveralls": "^2.11.9",
"del": "^2.2.2",
"gulp": "^3.9.1",
"jest": "^19.0.2",
"parse5": "^3.0.2",
"pify": "^2.3.0",
"polymer-bundler": "^2.0.1",
"polymer-cli": "^1.1.0",
"redux": "^3.0.5",
"redux-thunk": "^2.2.0",
"rollup": "^0.36.0",
"rollup-plugin-babel": "^2.6.1",
"rollup-plugin-commonjs": "^8.0.2",
"rollup-plugin-node-resolve": "^2.0.0",
"run-sequence": "^1.2.2",
"web-component-tester": "^6.2.0",
"xo": "^0.18.0"
}
}
1 change: 0 additions & 1 deletion src/index.html

This file was deleted.

11 changes: 9 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import window from 'global/window';
import console from 'global/console';
import {get} from '../../@polymer/polymer/lib/utils/path';

// Expose globals
const {CustomEvent, Polymer} = window;
const {CustomEvent} = window;

/**
* Polymer Redux
Expand Down Expand Up @@ -59,7 +60,7 @@ export default function PolymerRedux(store) {
const {statePath, readOnly} = properties[name];
const value = (typeof statePath === 'function') ?
statePath.call(element, state) :
Polymer.Path.get(state, statePath);
get(state, statePath);

if (readOnly) {
element._setProperty(name, value);
Expand Down Expand Up @@ -187,6 +188,12 @@ export default function PolymerRedux(store) {
});
return originalAction(...args);
};

// Copy props from the original action to the proxy.
// see https://github.com/tur-nr/polymer-redux/issues/98
Object.keys(originalAction).forEach(prop => {
action[prop] = originalAction[prop];
});
}

return store.dispatch(action);
Expand Down
Loading