components.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /**
  2. * DevExtreme (integration/knockout/components.js)
  3. * Version: 19.1.16
  4. * Build date: Tue Oct 18 2022
  5. *
  6. * Copyright (c) 2012 - 2022 Developer Express Inc. ALL RIGHTS RESERVED
  7. * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
  8. */
  9. "use strict";
  10. var ko = require("knockout");
  11. var iconUtils = require("../../core/utils/icon");
  12. ko.bindingHandlers.dxControlsDescendantBindings = {
  13. init: function(_, valueAccessor) {
  14. return {
  15. controlsDescendantBindings: ko.unwrap(valueAccessor())
  16. }
  17. }
  18. };
  19. ko.bindingHandlers.dxIcon = {
  20. init: function(element, valueAccessor) {
  21. var options = ko.utils.unwrapObservable(valueAccessor()) || {};
  22. var iconElement = iconUtils.getImageContainer(options);
  23. ko.virtualElements.emptyNode(element);
  24. if (iconElement) {
  25. ko.virtualElements.prepend(element, iconElement.get(0))
  26. }
  27. },
  28. update: function(element, valueAccessor) {
  29. var options = ko.utils.unwrapObservable(valueAccessor()) || {};
  30. var iconElement = iconUtils.getImageContainer(options);
  31. ko.virtualElements.emptyNode(element);
  32. if (iconElement) {
  33. ko.virtualElements.prepend(element, iconElement.get(0))
  34. }
  35. }
  36. };
  37. ko.virtualElements.allowedBindings.dxIcon = true;