"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;

exports.__esModule = true;
exports.default = void 0;

var _actionSetAttribute = _interopRequireDefault(require("./actionSetAttribute"));

var nonEntityPropNames = ['children', 'events', 'primitive'];

var filterNonEntityPropNames = function filterNonEntityPropNames(propName) {
  return nonEntityPropNames.indexOf(propName) === -1;
};

function updateAttributes(el, prevProps, props) {
  var propName;

  if (!props || prevProps === props) {
    return;
  }

  for (propName in props) {
    if (!filterNonEntityPropNames(propName)) {
      continue;
    }

    (0, _actionSetAttribute.default)(el, props, propName);
  }

  if (prevProps) {
    for (propName in prevProps) {
      if (!filterNonEntityPropNames(propName)) {
        continue;
      }

      if (props[propName] === undefined) {
        el.removeAttribute(propName);
      }
    }
  }
}

var _default = updateAttributes;
exports.default = _default;