Skip to content

Commit

Permalink
fix: Version Checks (#200)
Browse files Browse the repository at this point in the history
* refactor: remove unnecessary version check

* fix: replace parseFloat version comparsion with semver version comparsion

* refactor: remove debugger step
  • Loading branch information
Siolto authored Mar 24, 2022
1 parent 5bc2ccb commit 3648a98
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
18 changes: 12 additions & 6 deletions client-side-js/_navTo.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,26 @@ async function clientSide__navTo(sComponentId, sName, oParameters, oComponentTar
window.wdi5.Log.info(`[browser wdi5] navigation to ${sName} triggered`)

const router = sap.ui.getCore().getComponent(sComponentId).getRouter()
const hashChanger =
parseFloat(sap.ui.version) < 1.75
? sap.ui.core.routing.HashChanger.getInstance()
: router.getHashChanger()
const hashChanger = window.compareVersions.compare("1.75.0", sap.ui.version, ">")
? sap.ui.core.routing.HashChanger.getInstance()
: router.getHashChanger()

// on success result is the router
hashChanger.attachEvent("hashChanged", (oEvent) => {
done(["success", parseFloat(sap.ui.version) < 1.75 ? hashChanger.getHash() : hashChanger.hash])
done([
"success",
window.compareVersions.compare("1.75.0", sap.ui.version, ">")
? hashChanger.getHash()
: hashChanger.hash
])
})

// get component and trigger router
// sName, oParameters?, oComponentTargetInfo?, bReplace?
router.navTo(sName, oParameters, oComponentTargetInfo, bReplace)
return parseFloat(sap.ui.version) < 1.75 ? hashChanger.getHash() : hashChanger.hash
return window.compareVersions.compare("1.75.0", sap.ui.version, ">")
? hashChanger.getHash()
: hashChanger.hash
})
},
sComponentId,
Expand Down
6 changes: 5 additions & 1 deletion client-side-js/injectUI5.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ async function clientSide_injectUI5(config, waitForUI5Timeout) {
const isRootProperty =
oSelector.bindingPath.propertyPath &&
oSelector.bindingPath.propertyPath.charAt(0) === "/"
if (hasNamedModel && isRootProperty && parseFloat(sap.ui.version) < 1.81) {
if (
hasNamedModel &&
isRootProperty &&
window.compareVersions.compare("1.81.0", sap.ui.version, ">")
) {
// attach the double leading /
// for UI5 < 1.81
oSelector.bindingPath.propertyPath = `/${oSelector.bindingPath.propertyPath}`
Expand Down
11 changes: 1 addition & 10 deletions client-side-js/interactWithControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,7 @@ async function clientSide_interactWithControl(oOptions) {
.then(() => {
window.wdi5.Log.info("[browser wdi5] locating controlSelector")
oOptions.selector = window.wdi5.createMatcher(oOptions.selector)
if (parseFloat(sap.ui.version) <= 1.6) {
// implementing legacy api < 1.60
window.bridge.findDOMElementByControlSelector(oOptions).then((control, arg) => {
const ui5Control = window.wdi5.getUI5CtlForWebObj(control)
oOptions.control = ui5Control
return window.bridge.interactWithControl(oOptions)
})
} else {
return window.bridge.interactWithControl(oOptions)
}
return window.bridge.interactWithControl(oOptions)
})
.then((result) => {
window.wdi5.Log.info("[browser wdi5] interaction complete! - Message: " + result)
Expand Down

0 comments on commit 3648a98

Please sign in to comment.