MicrosoftEdge / MicrosoftEdge/WebView2Feedback

Property named "length" for an object added with the AddHostObjectToScript method always returns 0 in javascript

Open
#2,185 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug priority-low tracked
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

It seems that the "length" property is retrieved from the local javascript proxy object instead of the remote object, but a work-a-round is to do as follows:

// myobject name of object added AddHostObjectToScript
var myobject = chrome.webview.hostObjects.sync.myobject;
alert(myobject.length); // will always display 0
myobject._forceRemoteProperties.add("length"); // work-a-round
alert(myobject.length); // now shows the correct value for myobject.length

AB#38215318

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the JavaScript example using AddHostObjectToScript and a host object with a length property. Compare direct length access with access after adding length to _forceRemoteProperties; done means the remote value is returned without the workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api, desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.