Skip to content

Commit

Permalink
Merge pull request #24 from mindgamesdigital/clone-props
Browse files Browse the repository at this point in the history
Copy properties after cloning node
  • Loading branch information
JaySunSyn authored Apr 16, 2018
2 parents d039af4 + f95b950 commit a26c5ea
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions iron-swiper.html
Original file line number Diff line number Diff line change
Expand Up @@ -366,22 +366,25 @@
e.preventDefault();
}

_copyProperties(node1, node2) {
Object.keys(node1.constructor.properties).forEach(key => node2[key] = node1[key]);
}

init() {
clearTimeout(this._initializer);
this._initializer = setTimeout(function() {
// First clone real nodes into the wrapper
var _nodes = [];

const _nodes = [];
const excludeTagNames = ['TEMPLATE', 'DOM-REPEAT', 'DOM-IF'];
let slides = Polymer.FlattenedNodesObserver.getFlattenedNodes(this)
.filter(
function(node) {
return node.tagName &&
node.tagName !== 'TEMPLATE' &&
excludeTagNames.indexOf(node.tagName) === -1 &&
!node.classList.contains('swiper-slide');
});

var wrapper = this.$.wrapper;

const wrapper = this.$.wrapper;
wrapper.innerHTML = '';
wrapper.removeAttribute('style');

Expand All @@ -391,7 +394,8 @@
slides[i].classList.add('swiper-no-swiping');
}

var node = wrapper.appendChild(slides[i].cloneNode(true));
const node = wrapper.appendChild(slides[i].cloneNode(true));
this._copyProperties(slides[i], node);
node.classList.add('swiper-slide');
node.setAttribute('index', i.toString());
node.removeEventListener('click', this._nodeClicked);
Expand Down

0 comments on commit a26c5ea

Please sign in to comment.