framework7io / framework7

Full featured HTML framework for building iOS & Android apps
http://framework7.io
MIT License
18.04k stars 3.23k forks source link

page:beforein event not triggered on Chrome < 75 #4151

Open jacobg opened 1 year ago

jacobg commented 1 year ago

Framework7 version: [e.g. 3.0.0] 7.1.5 Vue.js version: [e.g. 2.0.0] 3.2.47 Platform and Target: Emulating iOS on Chrome browser

Describe the bug

page:beforein event is not triggered on Chrome < 75 (e.,g version 69). It works fine on new versions, e.g., version 111.

I tried to step through the debugger on both old and new Chrome, and compare where things are different. It seems that somehow the event listeners are different when iterating them in events-class emit function.

On Chrome 111, there are 8 listeners:

Screenshot 2023-03-17 at 2 53 34 PM

It's the last listener in the list that ends up calling the specific page:beforein handler.

On Chrome 69, there are only 7 listeners:

Screenshot 2023-03-17 at 2 53 51 PM

It seems that last listener is not there, which is why the page never receives the event.

Any ideas?

jacobg commented 1 year ago

I was able to workaround this issue by adding the following code to the page component

  beforeMount () {
    f7.on('pageBeforeIn', this.__FixPageBeforeIn_handler)
  },
  beforeUnmount () {
    f7.off('pageBeforeIn', this.__FixPageBeforeIn_handler)
  },
  methods: {
    __FixPageBeforeIn_handler (event) {
      if (event.pageEl === this.$el) {
        this.pageBeforeIn()
      }
    }
  }

I had also tried listening to page::init to subscribe to the beforein event there, but the page:init event is also not triggered!

page:afterin, page:beforeout and page:afterout are all triggered correctly.

I'm hoping to put together a minimal reproducible example soon.