天天看点

SAP UI5 Bootstrap脚本的实现原理

Can I change the hard code ID?

In SAP help the UI5 bootstrap logic is explained: Bootstrapping: Loading and Initializing SAPUI5 in HTML Pages.

However, I was asked by my colleague about one question: the script id below is hard coded. Can I change its id to any other value like HelloWorld?

SAP UI5 Bootstrap脚本的实现原理
SAP UI5 Bootstrap脚本的实现原理
SAP UI5 Bootstrap脚本的实现原理

Only if all the three evaluation fail, then framework will compare the script tag id with hard coded id “sap-ui-bootstrap” as last resort.

In my case, although I change the ID to “HelloWorld”, the second regular expression still succeed so resource root is successfully determined, no need to go the last ELSE-IF to compare the ID with hard coded value.

SAP UI5 Bootstrap脚本的实现原理
SAP UI5 Bootstrap脚本的实现原理

The code highlighted below parses the string and convert library name into an array: config.modules.

SAP UI5 Bootstrap脚本的实现原理
SAP UI5 Bootstrap脚本的实现原理