Anchor element's pathname returns undefined in Rhino with env.js

心不动则不痛 提交于 2019-12-04 17:16:31

Found it and fixed it. The pathname getter/setter simply was undefined for HTMLAnchorElement in env.js.

I submitted a pull request, but unfortunately the project looks all but abandoned. I also couldn't figure out how to build it out to a single file. It appears perhaps someone has taken it upon themselves to break it apart into require.js modules. Not a battle worth fighting for my use case.

So for anyone else who hits this issue, I have the code you need below. It belongs in the HTMLAnchorElement.prototype. In my copy of env.js 1.2, this prototype begins on line 8075. I added the following at line 8118.

get pathname() {
  var uri = Envjs.urlsplit(this.href);
  return uri.path;
},
set pathname(val) {
  var uri = Envjs.urlsplit(this.href);
  uri.path = val
  this.href(uri.urlunsplit(uri));
},

FYI, my particular issue is resolved with this pull request.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!