Browse Source

Replace native replaceWith

pull/2219/head
Artur Arseniev 7 years ago
parent
commit
2bfbb8c56c
  1. 3
      src/dom_components/view/ComponentView.js
  2. 4
      src/utils/dom.js

3
src/dom_components/view/ComponentView.js

@ -3,6 +3,7 @@ import { isArray, isEmpty, each, keys } from 'underscore';
import Components from '../model/Components';
import ComponentsView from './ComponentsView';
import Selectors from 'selector_manager/model/Selectors';
import { replaceWith } from 'utils/dom';
export default Backbone.View.extend({
className() {
@ -354,7 +355,7 @@ export default Backbone.View.extend({
this.el = '';
this._ensureElement();
this.$el.data({ model, collection });
el.replaceWith(this.el);
replaceWith(el, this.el);
this.render();
},

4
src/utils/dom.js

@ -9,6 +9,10 @@ export const empty = node => {
while (node.firstChild) node.removeChild(node.firstChild);
};
export const replaceWith = (oldEl, newEl) => {
oldEl.parentNode.replaceChild(newEl, oldEl);
};
export const appendAtIndex = (parent, child, index) => {
const { childNodes } = parent;
const total = childNodes.length;

Loading…
Cancel
Save