@ui5/webcomponents-base 0.0.0-f9b9eadb8 → 0.0.0-fd6264051

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (326) hide show
  1. package/.eslintignore +4 -0
  2. package/CHANGELOG.md +209 -0
  3. package/README.md +26 -2
  4. package/bundle.esm.js +13 -11
  5. package/dist/AssetRegistry.js +8 -9
  6. package/dist/Boot.js +59 -0
  7. package/dist/CSP.js +59 -0
  8. package/dist/CustomElementsRegistry.js +60 -4
  9. package/dist/DOMObserver.js +65 -0
  10. package/dist/Device.js +69 -776
  11. package/dist/EventProvider.js +30 -26
  12. package/dist/FeaturesRegistry.js +4 -1
  13. package/dist/FontFace.js +19 -62
  14. package/dist/InitialConfiguration.js +37 -21
  15. package/dist/Keys.js +83 -0
  16. package/dist/ManagedStyles.js +83 -0
  17. package/dist/MediaRange.js +109 -0
  18. package/{src/util/parseProperties.js → dist/PropertiesFileFormat.js} +6 -0
  19. package/dist/Render.js +175 -0
  20. package/dist/RenderScheduler.js +16 -138
  21. package/dist/Runtimes.js +107 -0
  22. package/dist/StaticArea.js +1 -29
  23. package/dist/StaticAreaItem.js +58 -65
  24. package/dist/SystemCSSVars.js +4 -25
  25. package/dist/UI5Element.js +306 -378
  26. package/dist/UI5ElementMetadata.js +131 -16
  27. package/dist/asset-registries/Icons.js +121 -14
  28. package/dist/asset-registries/Illustrations.js +30 -0
  29. package/dist/asset-registries/LocaleData.js +91 -67
  30. package/dist/asset-registries/Themes.js +23 -33
  31. package/dist/asset-registries/i18n.js +61 -50
  32. package/dist/assets-meta/IconCollectionsAlias.js +18 -0
  33. package/dist/config/Language.js +18 -20
  34. package/dist/config/Theme.js +25 -0
  35. package/dist/css/FontFace.css +45 -0
  36. package/dist/css/OverrideFontFace.css +32 -0
  37. package/dist/css/SystemCSSVars.css +17 -0
  38. package/dist/delegate/ItemNavigation.js +233 -201
  39. package/dist/delegate/ResizeHandler.js +78 -37
  40. package/dist/delegate/ScrollEnablement.js +49 -20
  41. package/dist/features/F6Navigation.js +106 -0
  42. package/dist/features/OpenUI5Support.js +41 -6
  43. package/dist/generated/AssetParameters.js +1 -1
  44. package/dist/generated/VersionInfo.js +10 -0
  45. package/dist/generated/css/FontFace.css.js +5 -0
  46. package/dist/generated/css/OverrideFontFace.css.js +5 -0
  47. package/dist/generated/css/SystemCSSVars.css.js +5 -0
  48. package/dist/i18nBundle.js +38 -4
  49. package/dist/isLegacyBrowser.js +3 -0
  50. package/dist/locale/applyDirection.js +6 -4
  51. package/dist/locale/directionChange.js +32 -0
  52. package/dist/locale/getEffectiveDir.js +28 -0
  53. package/dist/locale/getLocale.js +12 -2
  54. package/dist/locale/languageChange.js +1 -1
  55. package/dist/renderer/LitRenderer.js +24 -21
  56. package/dist/renderer/directives/style-map.js +72 -0
  57. package/dist/resources/bundle.esm.js +17 -109
  58. package/dist/resources/bundle.esm.js.map +1 -1
  59. package/dist/sap/base/Log.js +241 -0
  60. package/dist/sap/base/assert.js +8 -0
  61. package/dist/sap/base/security/URLListValidator.js +148 -0
  62. package/dist/sap/base/security/encodeCSS.js +14 -0
  63. package/dist/sap/base/security/encodeXML.js +23 -0
  64. package/dist/sap/base/security/sanitizeHTML.js +16 -0
  65. package/dist/sap/base/strings/toHex.js +8 -0
  66. package/dist/sap/base/util/now.js +7 -0
  67. package/dist/sap/ui/thirdparty/caja-html-sanitizer.js +3585 -0
  68. package/dist/test-resources/assets/Themes.js +8 -8
  69. package/dist/test-resources/elements/Parent.js +6 -2
  70. package/dist/test-resources/elements/WithStaticArea.js +2 -1
  71. package/dist/test-resources/pages/AllTestElements.html +3 -3
  72. package/dist/test-resources/pages/Configuration.html +0 -2
  73. package/dist/test-resources/pages/ConfigurationScript.html +0 -2
  74. package/dist/test-resources/pages/i18n.html +2 -9
  75. package/dist/test-resources/specs/ConfigurationChange.spec.js +10 -8
  76. package/dist/test-resources/specs/ConfigurationScript.spec.js +25 -23
  77. package/dist/test-resources/specs/ConfigurationURL.spec.js +65 -17
  78. package/dist/test-resources/specs/CustomTheme.spec.js +9 -7
  79. package/dist/test-resources/specs/EventProvider.spec.js +63 -0
  80. package/dist/test-resources/specs/StaticArea.spec.js +56 -12
  81. package/dist/test-resources/specs/Theming.spec.js +12 -10
  82. package/dist/test-resources/specs/UI5ElementInvalidation.js +54 -70
  83. package/dist/test-resources/specs/UI5ElementLifecycle.js +17 -15
  84. package/dist/test-resources/specs/UI5ElementListenForChildPropChanges.spec.js +25 -51
  85. package/dist/test-resources/specs/UI5ElementMetadataExt.js +9 -7
  86. package/dist/test-resources/specs/UI5ElementPropertyValidation.js +7 -5
  87. package/dist/test-resources/specs/UI5ElementPropsAndAttrs.spec.js +37 -35
  88. package/dist/test-resources/specs/UI5ElementShadowDOM.js +10 -8
  89. package/dist/test-resources/specs/UI5ElementSlots.js +10 -8
  90. package/dist/theming/CustomStyle.js +25 -5
  91. package/dist/theming/applyTheme.js +11 -16
  92. package/dist/theming/getConstructableStyle.js +7 -6
  93. package/dist/theming/getEffectiveLinksHrefs.js +20 -0
  94. package/dist/theming/getEffectiveStyle.js +15 -8
  95. package/dist/theming/getStylesString.js +4 -2
  96. package/dist/theming/getThemeDesignerTheme.js +25 -5
  97. package/dist/theming/preloadLinks.js +23 -0
  98. package/dist/types/CSSColor.js +9 -0
  99. package/dist/types/CalendarType.js +1 -1
  100. package/dist/types/DataType.js +13 -1
  101. package/dist/types/Float.js +4 -0
  102. package/dist/types/Integer.js +4 -0
  103. package/dist/types/InvisibleMessageMode.js +30 -0
  104. package/dist/types/ItemNavigationBehavior.js +2 -7
  105. package/dist/types/PopupState.js +1 -1
  106. package/dist/types/ValueState.js +1 -1
  107. package/dist/updateShadowRoot.js +30 -0
  108. package/dist/util/AriaLabelHelper.js +4 -4
  109. package/dist/util/Caret.js +45 -0
  110. package/dist/util/ColorConversion.js +370 -0
  111. package/dist/util/FocusableElements.js +22 -9
  112. package/dist/util/HTMLSanitizer.js +7 -0
  113. package/dist/util/InvisibleMessage.js +60 -0
  114. package/dist/util/PopupUtils.js +93 -0
  115. package/dist/util/SlotsHelper.js +43 -0
  116. package/dist/util/TabbableElements.js +5 -1
  117. package/dist/util/arraysAreEqual.js +15 -0
  118. package/dist/util/clamp.js +12 -0
  119. package/dist/util/createLinkInHead.js +19 -0
  120. package/dist/util/debounce.js +17 -0
  121. package/dist/util/escapeRegex.js +10 -0
  122. package/dist/util/generateHighlightedMarkup.js +42 -0
  123. package/dist/util/getActiveElement.js +11 -0
  124. package/dist/util/getClassCopy.js +10 -0
  125. package/dist/util/getEffectiveContentDensity.js +5 -0
  126. package/dist/util/isElementInView.js +15 -0
  127. package/dist/util/isNodeHidden.js +1 -1
  128. package/dist/util/isNodeTabbable.js +4 -4
  129. package/hash.txt +1 -0
  130. package/index.js +1 -1
  131. package/lib/generate-asset-parameters/index.js +0 -1
  132. package/lib/generate-styles/index.js +18 -0
  133. package/lib/generate-version-info/index.js +27 -0
  134. package/package-scripts.js +39 -19
  135. package/package.json +19 -13
  136. package/src/AssetRegistry.js +8 -9
  137. package/src/Boot.js +59 -0
  138. package/src/CSP.js +59 -0
  139. package/src/CustomElementsRegistry.js +60 -4
  140. package/src/DOMObserver.js +65 -0
  141. package/src/Device.js +69 -776
  142. package/src/EventProvider.js +30 -26
  143. package/src/FeaturesRegistry.js +4 -1
  144. package/src/FontFace.js +19 -62
  145. package/src/InitialConfiguration.js +37 -21
  146. package/src/Keys.js +83 -0
  147. package/src/ManagedStyles.js +83 -0
  148. package/src/MediaRange.js +109 -0
  149. package/{dist/util/parseProperties.js → src/PropertiesFileFormat.js} +6 -0
  150. package/src/Render.js +175 -0
  151. package/src/RenderScheduler.js +16 -138
  152. package/src/Runtimes.js +107 -0
  153. package/src/StaticArea.js +1 -29
  154. package/src/StaticAreaItem.js +58 -65
  155. package/src/SystemCSSVars.js +4 -25
  156. package/src/UI5Element.js +306 -378
  157. package/src/UI5ElementMetadata.js +131 -16
  158. package/src/asset-registries/Icons.js +121 -14
  159. package/src/asset-registries/Illustrations.js +30 -0
  160. package/src/asset-registries/LocaleData.js +91 -67
  161. package/src/asset-registries/Themes.js +23 -33
  162. package/src/asset-registries/i18n.js +61 -50
  163. package/src/assets-meta/IconCollectionsAlias.js +18 -0
  164. package/src/config/Language.js +18 -20
  165. package/src/config/Theme.js +25 -0
  166. package/src/css/FontFace.css +45 -0
  167. package/src/css/OverrideFontFace.css +32 -0
  168. package/src/css/SystemCSSVars.css +17 -0
  169. package/src/delegate/ItemNavigation.js +233 -201
  170. package/src/delegate/ResizeHandler.js +78 -37
  171. package/src/delegate/ScrollEnablement.js +49 -20
  172. package/src/features/F6Navigation.js +106 -0
  173. package/src/features/OpenUI5Support.js +41 -6
  174. package/src/i18nBundle.js +38 -4
  175. package/src/isLegacyBrowser.js +3 -0
  176. package/src/locale/applyDirection.js +6 -4
  177. package/src/locale/directionChange.js +32 -0
  178. package/src/locale/getEffectiveDir.js +28 -0
  179. package/src/locale/getLocale.js +12 -2
  180. package/src/locale/languageChange.js +1 -1
  181. package/src/renderer/LitRenderer.js +24 -21
  182. package/src/renderer/directives/style-map.js +72 -0
  183. package/src/theming/CustomStyle.js +25 -5
  184. package/src/theming/applyTheme.js +11 -16
  185. package/src/theming/getConstructableStyle.js +7 -6
  186. package/src/theming/getEffectiveLinksHrefs.js +20 -0
  187. package/src/theming/getEffectiveStyle.js +15 -8
  188. package/src/theming/getStylesString.js +4 -2
  189. package/src/theming/getThemeDesignerTheme.js +25 -5
  190. package/src/theming/preloadLinks.js +23 -0
  191. package/src/types/CSSColor.js +9 -0
  192. package/src/types/CalendarType.js +1 -1
  193. package/src/types/DataType.js +13 -1
  194. package/src/types/Float.js +4 -0
  195. package/src/types/Integer.js +4 -0
  196. package/src/types/InvisibleMessageMode.js +30 -0
  197. package/src/types/ItemNavigationBehavior.js +2 -7
  198. package/src/types/PopupState.js +1 -1
  199. package/src/types/ValueState.js +1 -1
  200. package/src/updateShadowRoot.js +30 -0
  201. package/src/util/AriaLabelHelper.js +4 -4
  202. package/src/util/Caret.js +45 -0
  203. package/src/util/ColorConversion.js +370 -0
  204. package/src/util/FocusableElements.js +22 -9
  205. package/src/util/HTMLSanitizer.js +7 -0
  206. package/src/util/InvisibleMessage.js +60 -0
  207. package/src/util/PopupUtils.js +93 -0
  208. package/src/util/SlotsHelper.js +43 -0
  209. package/src/util/TabbableElements.js +5 -1
  210. package/src/util/arraysAreEqual.js +15 -0
  211. package/src/util/clamp.js +12 -0
  212. package/src/util/createLinkInHead.js +19 -0
  213. package/src/util/debounce.js +17 -0
  214. package/src/util/escapeRegex.js +10 -0
  215. package/src/util/generateHighlightedMarkup.js +42 -0
  216. package/src/util/getActiveElement.js +11 -0
  217. package/src/util/getClassCopy.js +10 -0
  218. package/src/util/getEffectiveContentDensity.js +5 -0
  219. package/src/util/isElementInView.js +15 -0
  220. package/src/util/isNodeHidden.js +1 -1
  221. package/src/util/isNodeTabbable.js +4 -4
  222. package/used-modules.txt +10 -0
  223. package/bundle.es5.js +0 -28
  224. package/dist/SVGIconRegistry.js +0 -62
  225. package/dist/boot.js +0 -34
  226. package/dist/compatibility/DOMObserver.js +0 -62
  227. package/dist/compatibility/patchNodeValue.js +0 -24
  228. package/dist/compatibility/whenPolyfillLoaded.js +0 -26
  229. package/dist/config/AssetsPath.js +0 -17
  230. package/dist/delegate/CustomResize.js +0 -78
  231. package/dist/delegate/NativeResize.js +0 -45
  232. package/dist/features/PropertiesFormatSupport.js +0 -8
  233. package/dist/features/browsersupport/Edge.js +0 -6
  234. package/dist/features/browsersupport/IE11.js +0 -42
  235. package/dist/features/browsersupport/IE11WithWebComponentsPolyfill.js +0 -5
  236. package/dist/renderer/ifDefined.js +0 -21
  237. package/dist/renderer/scopeHTML.js +0 -32
  238. package/dist/resources/bundle.es5.js +0 -212
  239. package/dist/resources/bundle.es5.js.map +0 -1
  240. package/dist/theming/CSSVarsPonyfill.js +0 -48
  241. package/dist/theming/adaptCSSForIE.js +0 -95
  242. package/dist/theming/createComponentStyleTag.js +0 -54
  243. package/dist/theming/createThemePropertiesStyleTag.js +0 -20
  244. package/dist/thirdparty/Array.from.js +0 -16
  245. package/dist/thirdparty/Array.prototype.fill.js +0 -44
  246. package/dist/thirdparty/Array.prototype.find.js +0 -46
  247. package/dist/thirdparty/Array.prototype.includes.js +0 -51
  248. package/dist/thirdparty/Element.prototype.closest.js +0 -11
  249. package/dist/thirdparty/Element.prototype.matches.js +0 -6
  250. package/dist/thirdparty/Map.prototype.keys.js +0 -9
  251. package/dist/thirdparty/Number.isInteger.js +0 -5
  252. package/dist/thirdparty/Number.isNaN.js +0 -1
  253. package/dist/thirdparty/Number.parseFloat.js +0 -1
  254. package/dist/thirdparty/Number.parseInt.js +0 -1
  255. package/dist/thirdparty/Object.assign.js +0 -31
  256. package/dist/thirdparty/Object.entries.js +0 -11
  257. package/dist/thirdparty/Symbol.js +0 -2
  258. package/dist/thirdparty/WeakSet.js +0 -27
  259. package/dist/thirdparty/es6-string-methods.js +0 -182
  260. package/dist/thirdparty/events-polyfills.js +0 -89
  261. package/dist/thirdparty/fetch.js +0 -1
  262. package/dist/thirdparty/template.js +0 -600
  263. package/dist/thirdparty/webcomponents-sd-ce-pf.js +0 -318
  264. package/dist/util/EffectiveAssetPath.js +0 -27
  265. package/dist/util/isSlot.js +0 -3
  266. package/dist/webcomponentsjs/LICENSE.md +0 -19
  267. package/dist/webcomponentsjs/README.md +0 -229
  268. package/dist/webcomponentsjs/bundles/webcomponents-ce.js +0 -63
  269. package/dist/webcomponentsjs/bundles/webcomponents-ce.js.map +0 -1
  270. package/dist/webcomponentsjs/bundles/webcomponents-sd-ce-pf.js +0 -297
  271. package/dist/webcomponentsjs/bundles/webcomponents-sd-ce-pf.js.map +0 -1
  272. package/dist/webcomponentsjs/bundles/webcomponents-sd-ce.js +0 -208
  273. package/dist/webcomponentsjs/bundles/webcomponents-sd-ce.js.map +0 -1
  274. package/dist/webcomponentsjs/bundles/webcomponents-sd.js +0 -166
  275. package/dist/webcomponentsjs/bundles/webcomponents-sd.js.map +0 -1
  276. package/dist/webcomponentsjs/custom-elements-es5-adapter.js +0 -15
  277. package/dist/webcomponentsjs/package.json +0 -46
  278. package/dist/webcomponentsjs/src/entrypoints/custom-elements-es5-adapter-index.js +0 -16
  279. package/dist/webcomponentsjs/src/entrypoints/webcomponents-bundle-index.js +0 -53
  280. package/dist/webcomponentsjs/src/entrypoints/webcomponents-ce-index.js +0 -17
  281. package/dist/webcomponentsjs/src/entrypoints/webcomponents-sd-ce-index.js +0 -19
  282. package/dist/webcomponentsjs/src/entrypoints/webcomponents-sd-ce-pf-index.js +0 -28
  283. package/dist/webcomponentsjs/src/entrypoints/webcomponents-sd-index.js +0 -18
  284. package/dist/webcomponentsjs/webcomponents-bundle.js +0 -298
  285. package/dist/webcomponentsjs/webcomponents-bundle.js.map +0 -1
  286. package/dist/webcomponentsjs/webcomponents-loader.js +0 -185
  287. package/src/SVGIconRegistry.js +0 -62
  288. package/src/boot.js +0 -34
  289. package/src/compatibility/DOMObserver.js +0 -62
  290. package/src/compatibility/patchNodeValue.js +0 -24
  291. package/src/compatibility/whenPolyfillLoaded.js +0 -26
  292. package/src/config/AssetsPath.js +0 -17
  293. package/src/delegate/CustomResize.js +0 -78
  294. package/src/delegate/NativeResize.js +0 -45
  295. package/src/features/PropertiesFormatSupport.js +0 -8
  296. package/src/features/browsersupport/Edge.js +0 -6
  297. package/src/features/browsersupport/IE11.js +0 -42
  298. package/src/features/browsersupport/IE11WithWebComponentsPolyfill.js +0 -5
  299. package/src/renderer/ifDefined.js +0 -21
  300. package/src/renderer/scopeHTML.js +0 -32
  301. package/src/theming/CSSVarsPonyfill.js +0 -48
  302. package/src/theming/adaptCSSForIE.js +0 -95
  303. package/src/theming/createComponentStyleTag.js +0 -54
  304. package/src/theming/createThemePropertiesStyleTag.js +0 -20
  305. package/src/thirdparty/Array.from.js +0 -16
  306. package/src/thirdparty/Array.prototype.fill.js +0 -44
  307. package/src/thirdparty/Array.prototype.find.js +0 -46
  308. package/src/thirdparty/Array.prototype.includes.js +0 -51
  309. package/src/thirdparty/Element.prototype.closest.js +0 -11
  310. package/src/thirdparty/Element.prototype.matches.js +0 -6
  311. package/src/thirdparty/Map.prototype.keys.js +0 -9
  312. package/src/thirdparty/Number.isInteger.js +0 -5
  313. package/src/thirdparty/Number.isNaN.js +0 -1
  314. package/src/thirdparty/Number.parseFloat.js +0 -1
  315. package/src/thirdparty/Number.parseInt.js +0 -1
  316. package/src/thirdparty/Object.assign.js +0 -31
  317. package/src/thirdparty/Object.entries.js +0 -11
  318. package/src/thirdparty/Symbol.js +0 -2
  319. package/src/thirdparty/WeakSet.js +0 -27
  320. package/src/thirdparty/es6-string-methods.js +0 -182
  321. package/src/thirdparty/events-polyfills.js +0 -89
  322. package/src/thirdparty/fetch.js +0 -1
  323. package/src/thirdparty/template.js +0 -600
  324. package/src/thirdparty/webcomponents-sd-ce-pf.js +0 -318
  325. package/src/util/EffectiveAssetPath.js +0 -27
  326. package/src/util/isSlot.js +0 -3
@@ -1,36 +1,50 @@
1
1
  import merge from "./thirdparty/merge.js";
2
- import boot from "./boot.js";
2
+ import { boot } from "./Boot.js";
3
3
  import UI5ElementMetadata from "./UI5ElementMetadata.js";
4
- import executeTemplate from "./renderer/executeTemplate.js";
4
+ import EventProvider from "./EventProvider.js";
5
+ import getSingletonElementInstance from "./util/getSingletonElementInstance.js";
5
6
  import StaticAreaItem from "./StaticAreaItem.js";
6
- import RenderScheduler from "./RenderScheduler.js";
7
+ import updateShadowRoot from "./updateShadowRoot.js";
8
+ import { renderDeferred, renderImmediately, cancelRender } from "./Render.js";
7
9
  import { registerTag, isTagRegistered, recordTagRegistrationFailure } from "./CustomElementsRegistry.js";
8
- import DOMObserver from "./compatibility/DOMObserver.js";
10
+ import { observeDOMNode, unobserveDOMNode } from "./DOMObserver.js";
9
11
  import { skipOriginalEvent } from "./config/NoConflict.js";
10
- import { getRTL } from "./config/RTL.js";
11
- import getConstructableStyle from "./theming/getConstructableStyle.js";
12
- import createComponentStyleTag from "./theming/createComponentStyleTag.js";
13
- import getEffectiveStyle from "./theming/getEffectiveStyle.js";
14
- import Integer from "./types/Integer.js";
15
- import Float from "./types/Float.js";
12
+ import getEffectiveDir from "./locale/getEffectiveDir.js";
13
+ import DataType from "./types/DataType.js";
16
14
  import { kebabToCamelCase, camelToKebabCase } from "./util/StringHelper.js";
17
15
  import isValidPropertyName from "./util/isValidPropertyName.js";
18
- import isSlot from "./util/isSlot.js";
16
+ import isDescendantOf from "./util/isDescendantOf.js";
17
+ import { isSlot, getSlotName, getSlottedElementsList } from "./util/SlotsHelper.js";
18
+ import arraysAreEqual from "./util/arraysAreEqual.js";
19
+ import getClassCopy from "./util/getClassCopy.js";
19
20
  import { markAsRtlAware } from "./locale/RTLAwareRegistry.js";
20
-
21
- const metadata = {
22
- events: {
23
- "_property-change": {},
24
- },
25
- };
21
+ import preloadLinks from "./theming/preloadLinks.js";
26
22
 
27
23
  let autoId = 0;
28
24
 
29
25
  const elementTimeouts = new Map();
30
26
  const uniqueDependenciesCache = new Map();
31
27
 
32
- const GLOBAL_CONTENT_DENSITY_CSS_VAR = "--_ui5_content_density";
33
- const GLOBAL_DIR_CSS_VAR = "--_ui5_dir";
28
+ /**
29
+ * Triggers re-rendering of a UI5Element instance due to state change.
30
+ *
31
+ * @param changeInfo An object with information about the change that caused invalidation.
32
+ * @private
33
+ */
34
+ function _invalidate(changeInfo) {
35
+ // Invalidation should be suppressed: 1) before the component is rendered for the first time 2) and during the execution of onBeforeRendering
36
+ // This is necessary not only as an optimization, but also to avoid infinite loops on invalidation between children and parents (when invalidateOnChildChange is used)
37
+ if (this._suppressInvalidation) {
38
+ return;
39
+ }
40
+
41
+ // Call the onInvalidation hook
42
+ this.onInvalidation(changeInfo);
43
+
44
+ this._changedState.push(changeInfo);
45
+ renderDeferred(this);
46
+ this._eventProvider.fireEvent("invalidate", { ...changeInfo, target: this });
47
+ }
34
48
 
35
49
  /**
36
50
  * Base class for all UI5 Web Components
@@ -45,40 +59,26 @@ const GLOBAL_DIR_CSS_VAR = "--_ui5_dir";
45
59
  class UI5Element extends HTMLElement {
46
60
  constructor() {
47
61
  super();
48
- this._propertyChangeListeners = new Set();
49
- this._initializeState();
50
- this._upgradeAllProperties();
51
- this._initializeContainers();
52
- this._upToDate = false;
53
- this._inDOM = false;
54
- this._fullyConnected = false;
55
62
 
63
+ this._changedState = []; // Filled on each invalidation, cleared on re-render (used for debugging)
64
+ this._suppressInvalidation = true; // A flag telling whether all invalidations should be ignored. Initialized with "true" because a UI5Element can not be invalidated until it is rendered for the first time
65
+ this._inDOM = false; // A flag telling whether the UI5Element is currently in the DOM tree of the document or not
66
+ this._fullyConnected = false; // A flag telling whether the UI5Element's onEnterDOM hook was called (since it's possible to have the element removed from DOM before that)
67
+ this._childChangeListeners = new Map(); // used to store lazy listeners per slot for the child change event of every child inside that slot
68
+ this._slotChangeListeners = new Map(); // used to store lazy listeners per slot for the slotchange event of all slot children inside that slot
69
+ this._eventProvider = new EventProvider(); // used by parent components for listening to changes to child components
56
70
  let deferredResolve;
57
71
  this._domRefReadyPromise = new Promise(resolve => {
58
72
  deferredResolve = resolve;
59
73
  });
60
74
  this._domRefReadyPromise._deferredResolve = deferredResolve;
61
75
 
62
- this._monitoredChildProps = new Map();
63
- this._shouldInvalidateParent = false;
64
- }
65
-
66
- addEventListener(type, listener, options) {
67
- if (type === "_property-change") {
68
- this._propertyChangeListeners.add(listener);
69
- }
70
- return super.addEventListener(type, listener, options);
71
- }
76
+ this._initializeState();
77
+ this._upgradeAllProperties();
72
78
 
73
- removeEventListener(type, listener, options) {
74
- if (type === "_property-change") {
75
- this._propertyChangeListeners.delete(listener);
79
+ if (this.constructor._needsShadowDOM()) {
80
+ this.attachShadow({ mode: "open" });
76
81
  }
77
- return super.removeEventListener(type, listener, options);
78
- }
79
-
80
- _hasPropertyChangeListeners() {
81
- return !!this._propertyChangeListeners.size;
82
82
  }
83
83
 
84
84
  /**
@@ -95,32 +95,16 @@ class UI5Element extends HTMLElement {
95
95
  return this.__id;
96
96
  }
97
97
 
98
- /**
99
- * @private
100
- */
101
- _initializeContainers() {
102
- const needsShadowDOM = this.constructor._needsShadowDOM();
103
- const needsStaticArea = this.constructor._needsStaticArea();
104
-
105
- // Init Shadow Root
106
- if (needsShadowDOM) {
107
- this.attachShadow({ mode: "open" });
108
- }
109
-
110
- // Init StaticAreaItem only if needed
111
- if (needsStaticArea) {
112
- this.staticAreaItem = new StaticAreaItem(this);
113
- }
114
- }
115
-
116
98
  /**
117
99
  * Do not call this method from derivatives of UI5Element, use "onEnterDOM" only
118
100
  * @private
119
101
  */
120
102
  async connectedCallback() {
121
103
  this.setAttribute(this.constructor.getMetadata().getPureTag(), "");
104
+ if (this.constructor.getMetadata().supportsF6FastNavigation()) {
105
+ this.setAttribute("data-sap-ui-fastnavgroup", "true");
106
+ }
122
107
 
123
- const needsShadowDOM = this.constructor._needsShadowDOM();
124
108
  const slotsAreManaged = this.constructor.getMetadata().slotsAreManaged();
125
109
 
126
110
  this._inDOM = true;
@@ -131,23 +115,15 @@ class UI5Element extends HTMLElement {
131
115
  await this._processChildren();
132
116
  }
133
117
 
134
- // Render the Shadow DOM
135
- if (needsShadowDOM) {
136
- if (!this.shadowRoot) { // Workaround for Firefox74 bug
137
- await Promise.resolve();
138
- }
139
-
140
- if (!this._inDOM) { // Component removed from DOM while _processChildren was running
141
- return;
142
- }
118
+ if (!this._inDOM) { // Component removed from DOM while _processChildren was running
119
+ return;
120
+ }
143
121
 
144
- RenderScheduler.register(this);
145
- RenderScheduler.renderImmediately(this);
146
- this._domRefReadyPromise._deferredResolve();
147
- this._fullyConnected = true;
148
- if (typeof this.onEnterDOM === "function") {
149
- this.onEnterDOM();
150
- }
122
+ renderImmediately(this);
123
+ this._domRefReadyPromise._deferredResolve();
124
+ this._fullyConnected = true;
125
+ if (typeof this.onEnterDOM === "function") {
126
+ this.onEnterDOM();
151
127
  }
152
128
  }
153
129
 
@@ -156,8 +132,6 @@ class UI5Element extends HTMLElement {
156
132
  * @private
157
133
  */
158
134
  disconnectedCallback() {
159
- const needsShadowDOM = this.constructor._needsShadowDOM();
160
- const needsStaticArea = this.constructor._needsStaticArea();
161
135
  const slotsAreManaged = this.constructor.getMetadata().slotsAreManaged();
162
136
 
163
137
  this._inDOM = false;
@@ -166,21 +140,18 @@ class UI5Element extends HTMLElement {
166
140
  this._stopObservingDOMChildren();
167
141
  }
168
142
 
169
- if (needsShadowDOM) {
170
- RenderScheduler.deregister(this);
171
- if (this._fullyConnected) {
172
- if (typeof this.onExitDOM === "function") {
173
- this.onExitDOM();
174
- }
175
- this._fullyConnected = false;
143
+ if (this._fullyConnected) {
144
+ if (typeof this.onExitDOM === "function") {
145
+ this.onExitDOM();
176
146
  }
147
+ this._fullyConnected = false;
177
148
  }
178
149
 
179
- if (needsStaticArea) {
180
- this.staticAreaItem._removeFragmentFromStaticArea();
150
+ if (this.staticAreaItem && this.staticAreaItem.parentElement) {
151
+ this.staticAreaItem.parentElement.removeChild(this.staticAreaItem);
181
152
  }
182
153
 
183
- RenderScheduler.cancelRender(this);
154
+ cancelRender(this);
184
155
  }
185
156
 
186
157
  /**
@@ -196,16 +167,16 @@ class UI5Element extends HTMLElement {
196
167
  const mutationObserverOptions = {
197
168
  childList: true,
198
169
  subtree: canSlotText,
199
- characterData: true,
170
+ characterData: canSlotText,
200
171
  };
201
- DOMObserver.observeDOMNode(this, this._processChildren.bind(this), mutationObserverOptions);
172
+ observeDOMNode(this, this._processChildren.bind(this), mutationObserverOptions);
202
173
  }
203
174
 
204
175
  /**
205
176
  * @private
206
177
  */
207
178
  _stopObservingDOMChildren() {
208
- DOMObserver.unobserveDOMNode(this);
179
+ unobserveDOMNode(this);
209
180
  }
210
181
 
211
182
  /**
@@ -227,8 +198,14 @@ class UI5Element extends HTMLElement {
227
198
  const canSlotText = this.constructor.getMetadata().canSlotText();
228
199
  const domChildren = Array.from(canSlotText ? this.childNodes : this.children);
229
200
 
230
- // Init the _state object based on the supported slots
201
+ const slotsCachedContentMap = new Map(); // Store here the content of each slot before the mutation occurred
202
+ const propertyNameToSlotMap = new Map(); // Used for reverse lookup to determine to which slot the property name corresponds
203
+
204
+ // Init the _state object based on the supported slots and store the previous values
231
205
  for (const [slotName, slotData] of Object.entries(slotsMap)) { // eslint-disable-line
206
+ const propertyName = slotData.propertyName || slotName;
207
+ propertyNameToSlotMap.set(propertyName, slotName);
208
+ slotsCachedContentMap.set(propertyName, [...this._state[propertyName]]);
232
209
  this._clearSlot(slotName, slotData);
233
210
  }
234
211
 
@@ -237,7 +214,7 @@ class UI5Element extends HTMLElement {
237
214
 
238
215
  const allChildrenUpgraded = domChildren.map(async (child, idx) => {
239
216
  // Determine the type of the child (mainly by the slot attribute)
240
- const slotName = this.constructor._getSlotName(child);
217
+ const slotName = getSlotName(child);
241
218
  const slotData = slotsMap[slotName];
242
219
 
243
220
  // Check if the slotName is supported
@@ -275,16 +252,15 @@ class UI5Element extends HTMLElement {
275
252
 
276
253
  child = this.constructor.getMetadata().constructor.validateSlotValue(child, slotData);
277
254
 
278
- if (child.isUI5Element && slotData.listenFor) {
279
- this._attachChildPropertyUpdated(child, slotData.listenFor);
280
- }
281
-
282
- if (child.isUI5Element && slotData.invalidateParent) {
283
- child._shouldInvalidateParent = true;
255
+ // Listen for any invalidation on the child if invalidateOnChildChange is true or an object (ignore when false or not set)
256
+ if (child.isUI5Element && slotData.invalidateOnChildChange) {
257
+ const method = (child.attachInvalidate || child._attachChange).bind(child);
258
+ method(this._getChildChangeListener(slotName));
284
259
  }
285
260
 
261
+ // Listen for the slotchange event if the child is a slot itself
286
262
  if (isSlot(child)) {
287
- this._attachSlotChange(child);
263
+ this._attachSlotChange(child, slotName);
288
264
  }
289
265
 
290
266
  const propertyName = slotData.propertyName || slotName;
@@ -300,10 +276,33 @@ class UI5Element extends HTMLElement {
300
276
 
301
277
  // Distribute the child in the _state object, keeping the Light DOM order,
302
278
  // not the order elements are defined.
303
- slottedChildrenMap.forEach((children, slot) => {
304
- this._state[slot] = children.sort((a, b) => a.idx - b.idx).map(_ => _.child);
279
+ slottedChildrenMap.forEach((children, propertyName) => {
280
+ this._state[propertyName] = children.sort((a, b) => a.idx - b.idx).map(_ => _.child);
305
281
  });
306
- this._invalidate("slots");
282
+
283
+ // Compare the content of each slot with the cached values and invalidate for the ones that changed
284
+ let invalidated = false;
285
+ for (const [slotName, slotData] of Object.entries(slotsMap)) { // eslint-disable-line
286
+ const propertyName = slotData.propertyName || slotName;
287
+ if (!arraysAreEqual(slotsCachedContentMap.get(propertyName), this._state[propertyName])) {
288
+ _invalidate.call(this, {
289
+ type: "slot",
290
+ name: propertyNameToSlotMap.get(propertyName),
291
+ reason: "children",
292
+ });
293
+ invalidated = true;
294
+ }
295
+ }
296
+
297
+ // If none of the slots had an invalidation due to changes to immediate children,
298
+ // the change is considered to be text content of the default slot
299
+ if (!invalidated) {
300
+ _invalidate.call(this, {
301
+ type: "slot",
302
+ name: "default",
303
+ reason: "textcontent",
304
+ });
305
+ }
307
306
  }
308
307
 
309
308
  /**
@@ -312,25 +311,62 @@ class UI5Element extends HTMLElement {
312
311
  */
313
312
  _clearSlot(slotName, slotData) {
314
313
  const propertyName = slotData.propertyName || slotName;
315
-
316
- let children = this._state[propertyName];
317
- if (!Array.isArray(children)) {
318
- children = [children];
319
- }
314
+ const children = this._state[propertyName];
320
315
 
321
316
  children.forEach(child => {
322
317
  if (child && child.isUI5Element) {
323
- this._detachChildPropertyUpdated(child);
324
- child._shouldInvalidateParent = false;
318
+ const method = (child.detachInvalidate || child._detachChange).bind(child);
319
+ method(this._getChildChangeListener(slotName));
325
320
  }
326
321
 
327
322
  if (isSlot(child)) {
328
- this._detachSlotChange(child);
323
+ this._detachSlotChange(child, slotName);
329
324
  }
330
325
  });
331
326
 
332
327
  this._state[propertyName] = [];
333
- this._invalidate(propertyName, []);
328
+ }
329
+
330
+ /**
331
+ * Attach a callback that will be executed whenever the component is invalidated
332
+ *
333
+ * @param callback
334
+ * @public
335
+ */
336
+ attachInvalidate(callback) {
337
+ this._eventProvider.attachEvent("invalidate", callback);
338
+ }
339
+
340
+ /**
341
+ * Detach the callback that is executed whenever the component is invalidated
342
+ *
343
+ * @param callback
344
+ * @public
345
+ */
346
+ detachInvalidate(callback) {
347
+ this._eventProvider.detachEvent("invalidate", callback);
348
+ }
349
+
350
+ /**
351
+ * Callback that is executed whenever a monitored child changes its state
352
+ *
353
+ * @param slotName the slot in which a child was invalidated
354
+ * @param childChangeInfo the changeInfo object for the child in the given slot
355
+ * @private
356
+ */
357
+ _onChildChange(slotName, childChangeInfo) {
358
+ if (!this.constructor.getMetadata().shouldInvalidateOnChildChange(slotName, childChangeInfo.type, childChangeInfo.name)) {
359
+ return;
360
+ }
361
+
362
+ // The component should be invalidated as this type of change on the child is listened for
363
+ // However, no matter what changed on the child (property/slot), the invalidation is registered as "type=slot" for the component itself
364
+ _invalidate.call(this, {
365
+ type: "slot",
366
+ name: slotName,
367
+ reason: "childchange",
368
+ child: childChangeInfo.target,
369
+ });
334
370
  }
335
371
 
336
372
  /**
@@ -345,12 +381,8 @@ class UI5Element extends HTMLElement {
345
381
  const propertyTypeClass = properties[nameInCamelCase].type;
346
382
  if (propertyTypeClass === Boolean) {
347
383
  newValue = newValue !== null;
348
- }
349
- if (propertyTypeClass === Integer) {
350
- newValue = parseInt(newValue);
351
- }
352
- if (propertyTypeClass === Float) {
353
- newValue = parseFloat(newValue);
384
+ } else if (isDescendantOf(propertyTypeClass, DataType)) {
385
+ newValue = propertyTypeClass.attributeToProperty(newValue);
354
386
  }
355
387
  this[nameInCamelCase] = newValue;
356
388
  }
@@ -363,22 +395,24 @@ class UI5Element extends HTMLElement {
363
395
  if (!this.constructor.getMetadata().hasAttribute(name)) {
364
396
  return;
365
397
  }
366
-
367
- if (typeof newValue === "object") {
368
- return;
369
- }
370
-
398
+ const properties = this.constructor.getMetadata().getProperties();
399
+ const propertyTypeClass = properties[name].type;
371
400
  const attrName = camelToKebabCase(name);
372
401
  const attrValue = this.getAttribute(attrName);
373
- if (typeof newValue === "boolean") {
402
+
403
+ if (propertyTypeClass === Boolean) {
374
404
  if (newValue === true && attrValue === null) {
375
405
  this.setAttribute(attrName, "");
376
406
  } else if (newValue === false && attrValue !== null) {
377
407
  this.removeAttribute(attrName);
378
408
  }
379
- } else if (attrValue !== newValue) {
380
- this.setAttribute(attrName, newValue);
381
- }
409
+ } else if (isDescendantOf(propertyTypeClass, DataType)) {
410
+ this.setAttribute(attrName, propertyTypeClass.propertyToAttribute(newValue));
411
+ } else if (typeof newValue !== "object") {
412
+ if (attrValue !== newValue) {
413
+ this.setAttribute(attrName, newValue);
414
+ }
415
+ } // else { return; } // old object handling
382
416
  }
383
417
 
384
418
  /**
@@ -404,123 +438,96 @@ class UI5Element extends HTMLElement {
404
438
  * @private
405
439
  */
406
440
  _initializeState() {
407
- const defaultState = this.constructor._getDefaultState();
408
- this._state = Object.assign({}, defaultState);
441
+ this._state = { ...this.constructor.getMetadata().getInitialState() };
409
442
  }
410
443
 
411
444
  /**
445
+ * Returns a singleton event listener for the "change" event of a child in a given slot
446
+ *
447
+ * @param slotName the name of the slot, where the child is
448
+ * @returns {any}
412
449
  * @private
413
450
  */
414
- _attachChildPropertyUpdated(child, listenFor) {
415
- const slotName = this.constructor._getSlotName(child); // all slotted children have the same configuration
416
-
417
- let observedProps = [],
418
- notObservedProps = [];
419
-
420
- if (Array.isArray(listenFor)) {
421
- observedProps = listenFor;
422
- } else {
423
- observedProps = Array.isArray(listenFor.include) ? listenFor.include : [];
424
- notObservedProps = Array.isArray(listenFor.exclude) ? listenFor.exclude : [];
451
+ _getChildChangeListener(slotName) {
452
+ if (!this._childChangeListeners.has(slotName)) {
453
+ this._childChangeListeners.set(slotName, this._onChildChange.bind(this, slotName));
425
454
  }
426
-
427
- if (!this._monitoredChildProps.has(slotName)) {
428
- this._monitoredChildProps.set(slotName, { observedProps, notObservedProps });
429
- }
430
-
431
- child.addEventListener("_property-change", this._invalidateParentOnPropertyUpdate);
455
+ return this._childChangeListeners.get(slotName);
432
456
  }
433
457
 
434
458
  /**
459
+ * Returns a singleton slotchange event listener that invalidates the component due to changes in the given slot
460
+ *
461
+ * @param slotName the name of the slot, where the slot element (whose slotchange event we're listening to) is
462
+ * @returns {any}
435
463
  * @private
436
464
  */
437
- _detachChildPropertyUpdated(child) {
438
- child.removeEventListener("_property-change", this._invalidateParentOnPropertyUpdate);
439
- }
440
-
441
- /**
442
- * @private
443
- */
444
- _propertyChange(name, value) {
445
- this._updateAttribute(name, value);
446
-
447
- if (this._hasPropertyChangeListeners()) {
448
- this.dispatchEvent(new CustomEvent("_property-change", {
449
- detail: { name, newValue: value },
450
- composed: false,
451
- bubbles: false,
452
- }));
465
+ _getSlotChangeListener(slotName) {
466
+ if (!this._slotChangeListeners.has(slotName)) {
467
+ this._slotChangeListeners.set(slotName, this._onSlotChange.bind(this, slotName));
453
468
  }
469
+ return this._slotChangeListeners.get(slotName);
454
470
  }
455
471
 
456
472
  /**
457
473
  * @private
458
474
  */
459
- _invalidateParentOnPropertyUpdate(prop) {
460
- // The web component to be invalidated
461
- const parentNode = this.parentNode;
462
- if (!parentNode) {
463
- return;
464
- }
465
-
466
- const slotName = parentNode.constructor._getSlotName(this);
467
- const propsMetadata = parentNode._monitoredChildProps.get(slotName);
468
-
469
- if (!propsMetadata) {
470
- return;
471
- }
472
- const { observedProps, notObservedProps } = propsMetadata;
473
-
474
- const allPropertiesAreObserved = observedProps.length === 1 && observedProps[0] === "*";
475
- const shouldObserve = allPropertiesAreObserved || observedProps.includes(prop.detail.name);
476
- const shouldSkip = notObservedProps.includes(prop.detail.name);
477
- if (shouldObserve && !shouldSkip) {
478
- parentNode._invalidate("_parent_", this);
479
- }
475
+ _attachSlotChange(child, slotName) {
476
+ child.addEventListener("slotchange", this._getSlotChangeListener(slotName));
480
477
  }
481
478
 
482
479
  /**
483
480
  * @private
484
481
  */
485
- _attachSlotChange(child) {
486
- if (!this._invalidateOnSlotChange) {
487
- this._invalidateOnSlotChange = () => {
488
- this._invalidate("slotchange");
489
- };
490
- }
491
- child.addEventListener("slotchange", this._invalidateOnSlotChange);
482
+ _detachSlotChange(child, slotName) {
483
+ child.removeEventListener("slotchange", this._getSlotChangeListener(slotName));
492
484
  }
493
485
 
494
486
  /**
487
+ * Whenever a slot element is slotted inside a UI5 Web Component, its slotchange event invalidates the component
488
+ *
489
+ * @param slotName the name of the slot, where the slot element (whose slotchange event we're listening to) is
495
490
  * @private
496
491
  */
497
- _detachSlotChange(child) {
498
- child.removeEventListener("slotchange", this._invalidateOnSlotChange);
492
+ _onSlotChange(slotName) {
493
+ _invalidate.call(this, {
494
+ type: "slot",
495
+ name: slotName,
496
+ reason: "slotchange",
497
+ });
499
498
  }
500
499
 
501
500
  /**
502
- * Asynchronously re-renders an already rendered web component
503
- * @private
501
+ * A callback that is executed each time an already rendered component is invalidated (scheduled for re-rendering)
502
+ *
503
+ * @param changeInfo An object with information about the change that caused invalidation.
504
+ * The object can have the following properties:
505
+ * - type: (property|slot) tells what caused the invalidation
506
+ * 1) property: a property value was changed either directly or as a result of changing the corresponding attribute
507
+ * 2) slot: a slotted node(nodes) changed in one of several ways (see "reason")
508
+ *
509
+ * - name: the name of the property or slot that caused the invalidation
510
+ *
511
+ * - reason: (children|textcontent|childchange|slotchange) relevant only for type="slot" only and tells exactly what changed in the slot
512
+ * 1) children: immediate children (HTML elements or text nodes) were added, removed or reordered in the slot
513
+ * 2) textcontent: text nodes in the slot changed value (or nested text nodes were added or changed value). Can only trigger for slots of "type: Node"
514
+ * 3) slotchange: a slot element, slotted inside that slot had its "slotchange" event listener called. This practically means that transitively slotted children changed.
515
+ * Can only trigger if the child of a slot is a slot element itself.
516
+ * 4) childchange: indicates that a UI5Element child in that slot was invalidated and in turn invalidated the component.
517
+ * Can only trigger for slots with "invalidateOnChildChange" metadata descriptor
518
+ *
519
+ * - newValue: the new value of the property (for type="property" only)
520
+ *
521
+ * - oldValue: the old value of the property (for type="property" only)
522
+ *
523
+ * - child the child that was changed (for type="slot" and reason="childchange" only)
524
+ *
525
+ * @public
504
526
  */
505
- _invalidate() {
506
- if (this._shouldInvalidateParent) {
507
- this.parentNode._invalidate();
508
- }
509
-
510
- if (!this._upToDate) {
511
- // console.log("already invalidated", this, ...arguments);
512
- return;
513
- }
514
-
515
- if (this.getDomRef() && !this._suppressInvalidation) {
516
- this._upToDate = false;
517
- // console.log("INVAL", this, ...arguments);
518
- RenderScheduler.renderDeferred(this);
519
- }
520
- }
527
+ onInvalidation(changeInfo) {}
521
528
 
522
529
  /**
523
- * Do not call this method directly, only intended to be called by RenderScheduler.js
530
+ * Do not call this method directly, only intended to be called by js
524
531
  * @protected
525
532
  */
526
533
  _render() {
@@ -539,15 +546,37 @@ class UI5Element extends HTMLElement {
539
546
  }
540
547
 
541
548
  // resume normal invalidation handling
542
- delete this._suppressInvalidation;
549
+ this._suppressInvalidation = false;
543
550
 
544
551
  // Update the shadow root with the render result
545
- // console.log(this.getDomRef() ? "RE-RENDER" : "FIRST RENDER", this);
546
- this._upToDate = true;
547
- this._updateShadowRoot();
552
+ /*
553
+ if (this._changedState.length) {
554
+ let element = this.localName;
555
+ if (this.id) {
556
+ element = `${element}#${this.id}`;
557
+ }
558
+ console.log("Re-rendering:", element, this._changedState.map(x => { // eslint-disable-line
559
+ let res = `${x.type}`;
560
+ if (x.reason) {
561
+ res = `${res}(${x.reason})`;
562
+ }
563
+ res = `${res}: ${x.name}`;
564
+ if (x.type === "property") {
565
+ res = `${res} ${x.oldValue} => ${x.newValue}`;
566
+ }
548
567
 
549
- if (this._shouldUpdateFragment()) {
550
- this.staticAreaItem._updateFragment(this);
568
+ return res;
569
+ }));
570
+ }
571
+ */
572
+ this._changedState = [];
573
+
574
+ // Update shadow root and static area item
575
+ if (this.constructor._needsShadowDOM()) {
576
+ updateShadowRoot(this);
577
+ }
578
+ if (this.staticAreaItem) {
579
+ this.staticAreaItem.update();
551
580
  }
552
581
 
553
582
  // Safari requires that children get the slot attribute only after the slot tags have been rendered in the shadow DOM
@@ -561,35 +590,6 @@ class UI5Element extends HTMLElement {
561
590
  }
562
591
  }
563
592
 
564
- /**
565
- * @private
566
- */
567
- _updateShadowRoot() {
568
- if (!this.constructor._needsShadowDOM()) {
569
- return;
570
- }
571
-
572
- let styleToPrepend;
573
- const renderResult = executeTemplate(this.constructor.template, this);
574
-
575
- // IE11, Edge
576
- if (window.ShadyDOM) {
577
- createComponentStyleTag(this.constructor);
578
- }
579
-
580
- // Chrome
581
- if (document.adoptedStyleSheets) {
582
- this.shadowRoot.adoptedStyleSheets = getConstructableStyle(this.constructor);
583
- }
584
-
585
- // FF, Safari
586
- if (!document.adoptedStyleSheets && !window.ShadyDOM) {
587
- styleToPrepend = getEffectiveStyle(this.constructor);
588
- }
589
-
590
- this.constructor.render(renderResult, this.shadowRoot, styleToPrepend, { eventContext: this });
591
- }
592
-
593
593
  /**
594
594
  * @private
595
595
  */
@@ -612,16 +612,27 @@ class UI5Element extends HTMLElement {
612
612
 
613
613
  /**
614
614
  * Returns the DOM Element inside the Shadow Root that corresponds to the opening tag in the UI5 Web Component's template
615
+ * *Note:* For logical (abstract) elements (items, options, etc...), returns the part of the parent's DOM that represents this option
615
616
  * Use this method instead of "this.shadowRoot" to read the Shadow DOM, if ever necessary
617
+ *
616
618
  * @public
617
619
  */
618
620
  getDomRef() {
621
+ // If a component set _getRealDomRef to its children, use the return value of this function
622
+ if (typeof this._getRealDomRef === "function") {
623
+ return this._getRealDomRef();
624
+ }
625
+
619
626
  if (!this.shadowRoot || this.shadowRoot.children.length === 0) {
620
627
  return;
621
628
  }
622
629
 
623
- return this.shadowRoot.children.length === 1
624
- ? this.shadowRoot.children[0] : this.shadowRoot.children[1];
630
+ const children = [...this.shadowRoot.children].filter(child => !["link", "style"].includes(child.localName));
631
+ if (children.length !== 1) {
632
+ console.warn(`The shadow DOM for ${this.constructor.getMetadata().getTag()} does not have a top level element, the getDomRef() method might not work as expected`); // eslint-disable-line
633
+ }
634
+
635
+ return children[0];
625
636
  }
626
637
 
627
638
  /**
@@ -638,12 +649,13 @@ class UI5Element extends HTMLElement {
638
649
  }
639
650
 
640
651
  /**
641
- * Use this method in order to get a reference to element in the shadow root of a web component
652
+ * Waits for dom ref and then returns the DOM Element marked with "data-sap-focus-ref" inside the template.
653
+ * This is the element that will receive the focus by default.
642
654
  * @public
643
- * @param {String} refName Defines the name of the stable DOM ref
644
655
  */
645
- getStableDomRef(refName) {
646
- return this.getDomRef().querySelector(`[data-ui5-stable=${refName}]`);
656
+ async getFocusDomRefAsync() {
657
+ await this._waitForDomRef();
658
+ return this.getFocusDomRef();
647
659
  }
648
660
 
649
661
  /**
@@ -681,8 +693,6 @@ class UI5Element extends HTMLElement {
681
693
  }
682
694
 
683
695
  _fireEvent(name, data, cancelable = false, bubbles = true) {
684
- let compatEventResult = true; // Initialized to true, because if the event is not fired at all, it should be considered "not-prevented"
685
-
686
696
  const noConflictEvent = new CustomEvent(`ui5-${name}`, {
687
697
  detail: data,
688
698
  composed: false,
@@ -690,14 +700,14 @@ class UI5Element extends HTMLElement {
690
700
  cancelable,
691
701
  });
692
702
 
693
- // This will be false if the compat event is prevented
694
- compatEventResult = this.dispatchEvent(noConflictEvent);
703
+ // This will be false if the no-conflict event is prevented
704
+ const noConflictEventResult = this.dispatchEvent(noConflictEvent);
695
705
 
696
706
  if (skipOriginalEvent(name)) {
697
- return compatEventResult;
707
+ return noConflictEventResult;
698
708
  }
699
709
 
700
- const customEvent = new CustomEvent(name, {
710
+ const normalEvent = new CustomEvent(name, {
701
711
  detail: data,
702
712
  composed: false,
703
713
  bubbles,
@@ -705,10 +715,10 @@ class UI5Element extends HTMLElement {
705
715
  });
706
716
 
707
717
  // This will be false if the normal event is prevented
708
- const normalEventResult = this.dispatchEvent(customEvent);
718
+ const normalEventResult = this.dispatchEvent(normalEvent);
709
719
 
710
720
  // Return false if any of the two events was prevented (its result was false).
711
- return normalEventResult && compatEventResult;
721
+ return normalEventResult && noConflictEventResult;
712
722
  }
713
723
 
714
724
  /**
@@ -717,18 +727,7 @@ class UI5Element extends HTMLElement {
717
727
  * @public
718
728
  */
719
729
  getSlottedNodes(slotName) {
720
- const reducer = (acc, curr) => {
721
- if (!isSlot(curr)) {
722
- return acc.concat([curr]);
723
- }
724
- return acc.concat(curr.assignedNodes({ flatten: true }).filter(item => item instanceof HTMLElement));
725
- };
726
-
727
- return this[slotName].reduce(reducer, []);
728
- }
729
-
730
- get isCompact() {
731
- return getComputedStyle(this).getPropertyValue(GLOBAL_CONTENT_DENSITY_CSS_VAR) === "compact";
730
+ return getSlottedElementsList(this[slotName]);
732
731
  }
733
732
 
734
733
  /**
@@ -740,33 +739,7 @@ class UI5Element extends HTMLElement {
740
739
  */
741
740
  get effectiveDir() {
742
741
  markAsRtlAware(this.constructor); // if a UI5 Element calls this method, it's considered to be rtl-aware
743
-
744
- const doc = window.document;
745
- const dirValues = ["ltr", "rtl"]; // exclude "auto" and "" from all calculations
746
- const locallyAppliedDir = getComputedStyle(this).getPropertyValue(GLOBAL_DIR_CSS_VAR);
747
-
748
- // In that order, inspect the CSS Var (for modern browsers), the element itself, html and body (for IE fallback)
749
- if (dirValues.includes(locallyAppliedDir)) {
750
- return locallyAppliedDir;
751
- }
752
- if (dirValues.includes(this.dir)) {
753
- return this.dir;
754
- }
755
- if (dirValues.includes(doc.documentElement.dir)) {
756
- return doc.documentElement.dir;
757
- }
758
- if (dirValues.includes(doc.body.dir)) {
759
- return doc.body.dir;
760
- }
761
-
762
- // Finally, check the configuration for explicitly set RTL or language-implied RTL
763
- return getRTL() ? "rtl" : undefined;
764
- }
765
-
766
- updateStaticAreaItemContentDensity() {
767
- if (this.staticAreaItem) {
768
- this.staticAreaItem._updateContentDensity(this.isCompact);
769
- }
742
+ return getEffectiveDir(this);
770
743
  }
771
744
 
772
745
  /**
@@ -786,26 +759,6 @@ class UI5Element extends HTMLElement {
786
759
  return this.getMetadata().getAttributesList();
787
760
  }
788
761
 
789
- /**
790
- * @private
791
- */
792
- static _getSlotName(child) {
793
- // Text nodes can only go to the default slot
794
- if (!(child instanceof HTMLElement)) {
795
- return "default";
796
- }
797
-
798
- // Discover the slot based on the real slot name (f.e. footer => footer, or content-32 => content)
799
- const slot = child.getAttribute("slot");
800
- if (slot) {
801
- const match = slot.match(/^(.+?)-\d+$/);
802
- return match ? match[1] : slot;
803
- }
804
-
805
- // Use default slot as a fallback
806
- return "default";
807
- }
808
-
809
762
  /**
810
763
  * @private
811
764
  */
@@ -813,70 +766,30 @@ class UI5Element extends HTMLElement {
813
766
  return !!this.template;
814
767
  }
815
768
 
816
- _shouldUpdateFragment() {
817
- return this.constructor._needsStaticArea() && this.staticAreaItem.isRendered();
818
- }
819
-
820
769
  /**
821
770
  * @private
822
771
  */
823
772
  static _needsStaticArea() {
824
- return typeof this.staticAreaTemplate === "function";
773
+ return !!this.staticAreaTemplate;
825
774
  }
826
775
 
827
776
  /**
828
777
  * @public
829
778
  */
830
779
  getStaticAreaItemDomRef() {
831
- return this.staticAreaItem.getDomRef();
832
- }
833
-
834
- /**
835
- * @private
836
- */
837
- static _getDefaultState() {
838
- if (this._defaultState) {
839
- return this._defaultState;
780
+ if (!this.constructor._needsStaticArea()) {
781
+ throw new Error("This component does not use the static area");
840
782
  }
841
783
 
842
- const MetadataClass = this.getMetadata();
843
- const defaultState = {};
844
- const slotsAreManaged = MetadataClass.slotsAreManaged();
845
-
846
- // Initialize properties
847
- const props = MetadataClass.getProperties();
848
- for (const propName in props) { // eslint-disable-line
849
- const propType = props[propName].type;
850
- const propDefaultValue = props[propName].defaultValue;
851
-
852
- if (propType === Boolean) {
853
- defaultState[propName] = false;
854
-
855
- if (propDefaultValue !== undefined) {
856
- console.warn("The 'defaultValue' metadata key is ignored for all booleans properties, they would be initialized with 'false' by default"); // eslint-disable-line
857
- }
858
- } else if (props[propName].multiple) {
859
- defaultState[propName] = [];
860
- } else if (propType === Object) {
861
- defaultState[propName] = "defaultValue" in props[propName] ? props[propName].defaultValue : {};
862
- } else if (propType === String) {
863
- defaultState[propName] = "defaultValue" in props[propName] ? props[propName].defaultValue : "";
864
- } else {
865
- defaultState[propName] = propDefaultValue;
866
- }
784
+ if (!this.staticAreaItem) {
785
+ this.staticAreaItem = StaticAreaItem.createInstance();
786
+ this.staticAreaItem.setOwnerElement(this);
867
787
  }
868
-
869
- // Initialize slots
870
- if (slotsAreManaged) {
871
- const slots = MetadataClass.getSlots();
872
- for (const [slotName, slotData] of Object.entries(slots)) { // eslint-disable-line
873
- const propertyName = slotData.propertyName || slotName;
874
- defaultState[propertyName] = [];
875
- }
788
+ if (!this.staticAreaItem.parentElement) {
789
+ getSingletonElementInstance("ui5-static-area").appendChild(this.staticAreaItem);
876
790
  }
877
791
 
878
- this._defaultState = defaultState;
879
- return defaultState;
792
+ return this.staticAreaItem.getDomRef();
880
793
  }
881
794
 
882
795
  /**
@@ -928,14 +841,27 @@ class UI5Element extends HTMLElement {
928
841
  }
929
842
  },
930
843
  set(value) {
844
+ let isDifferent;
931
845
  value = this.constructor.getMetadata().constructor.validatePropertyValue(value, propData);
932
846
 
933
847
  const oldState = this._state[prop];
848
+ if (propData.multiple && propData.compareValues) {
849
+ isDifferent = !arraysAreEqual(oldState, value);
850
+ } else if (isDescendantOf(propData.type, DataType)) {
851
+ isDifferent = !propData.type.valuesAreEqual(oldState, value);
852
+ } else {
853
+ isDifferent = oldState !== value;
854
+ }
934
855
 
935
- if (oldState !== value) {
856
+ if (isDifferent) {
936
857
  this._state[prop] = value;
937
- this._invalidate(prop, value);
938
- this._propertyChange(prop, value);
858
+ _invalidate.call(this, {
859
+ type: "property",
860
+ name: prop,
861
+ newValue: value,
862
+ oldValue: oldState,
863
+ });
864
+ this._updateAttribute(prop, value);
939
865
  }
940
866
  },
941
867
  });
@@ -958,7 +884,7 @@ class UI5Element extends HTMLElement {
958
884
  return [];
959
885
  },
960
886
  set() {
961
- throw new Error("Cannot set slots directly, use the DOM APIs");
887
+ throw new Error("Cannot set slot content directly, use the DOM APIs (appendChild, removeChild, etc...)");
962
888
  },
963
889
  });
964
890
  }
@@ -970,7 +896,7 @@ class UI5Element extends HTMLElement {
970
896
  * @protected
971
897
  */
972
898
  static get metadata() {
973
- return metadata;
899
+ return {};
974
900
  }
975
901
 
976
902
  /**
@@ -1058,11 +984,13 @@ class UI5Element extends HTMLElement {
1058
984
  this._generateAccessors();
1059
985
  registerTag(tag);
1060
986
  window.customElements.define(tag, this);
987
+ preloadLinks(this);
1061
988
 
1062
989
  if (altTag && !customElements.get(altTag)) {
1063
- class oldClassName extends this {}
1064
990
  registerTag(altTag);
1065
- window.customElements.define(altTag, oldClassName);
991
+ window.customElements.define(altTag, getClassCopy(this, () => {
992
+ console.log(`The ${altTag} tag is deprecated and will be removed in the next release, please use ${tag} instead.`); // eslint-disable-line
993
+ }));
1066
994
  }
1067
995
  }
1068
996
  return this;