Unexpected behavior from space character in webapp

I am using a specific static web app for my purposes, so I cannot switch environment and all functionality needs to be in the font.

I need to substitute many characters in certain contexts, so I am using contextual alternates.
It works fine until use a space character.
I can substitute the space, but no matter if it is replaced or not, it ruins the context; it does not understand that there are characters before the space character.

It works when I test it in other software, for example Photoshop.

Are there any workarounds for this, or just ideas on how I can make it work as expected?

I believe this is because the words are shaped individually so that the result can be reused across the webpage. Therefore, shaping cannot happen across word boundaries. This is a behavior of many web browsers and I don’t think it can be disabled.

Thanks for the response.
If it can be disabled, what type of phrasing would I be looking for?

My best solution so far is that the user would be required to use underscore instead of space, but that is obviously suboptimal.

Any ideas of ways to “hack” this to be able to use the space character?

I don’t think there is a way to change it, hack or not.

You can ask the people who wrote the browser. A font cannot fix or circumvent a shaping engine.

I’m certain that you know more about shaping engines than I do, but shaping engines do give some level of control to the font, right? So might there be a way for the font to override this behaviour if there are some scenarios where the shaping engine doesn’t isolate words (maybe by tagging a certain script or language), or if the shaping engine allows some types of OpenType features to be applied before the words are isolated (maybe rvrn?).

If there are any possible hacks, it would be easier to find them after @mawns reveals which OS/web app/browser this is for.

Actually, I discovered now that it works as expected in Safari. So Chrome (at least) is the problematic browser, on both Mac and Windows.

It is a .NET app, more than that I do not know.