Search code examples
javascriptiosgithubweb-component

webapp unresponsive after argelius' favorite-star


after using argelius' favorite star in an iOS webapp its js becomes unresponsive. In desktop safari it works but gives the error Refused to get unsafe header "Location", after digging around that seems to be unrelated but I thought I should mention it.

Any ideas?

Maybe something is wrong in the way I implemented it, this is the first GitHub repository I implement.

this code is in <head>:

<script src="https://argelius.github.io/favorite-star/bower_components/webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="https://argelius.github.io/favorite-star/favorite-star.html">

EDIT: after using iOS web inspector I found that scope.wrappers.Window returned null, digging further I found this solution:

change:

function getDescriptor(source, name) {
  try {
    return Object.getOwnPropertyDescriptor(source, name);
  } catch (ex) {
    return dummyDescriptor;
  }
}

for:

function getDescriptor(source, name) {
  try {
    var desc = Object.getOwnPropertyDescriptor(source, name);
    if (desc) return desc;
  } catch (ex) {
    // Just return a dummy descriptor
  }
  return dummyDescriptor;
}

Solution

  • after using iOS web inspector I found that scope.wrappers.Window returned null, digging further I found this solution:

    change:

    function getDescriptor(source, name) {
      try {
        return Object.getOwnPropertyDescriptor(source, name);
      } catch (ex) {
        return dummyDescriptor;
      }
    }
    

    for:

    function getDescriptor(source, name) {
      try {
        var desc = Object.getOwnPropertyDescriptor(source, name);
        if (desc) return desc;
      } catch (ex) {
        // Just return a dummy descriptor
      }
      return dummyDescriptor;
    }
    

    credit: https://github.com/webcomponents/webcomponentsjs/issues/628