-
-
Notifications
You must be signed in to change notification settings - Fork 989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/59 create with html element instead of id only #697
base: master
Are you sure you want to change the base?
Feature/59 create with html element instead of id only #697
Conversation
Accept both HTML Element & Element Id as parameters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR looks good, the approach is very useful in cases where we need to pass an element on demand or need to choose the element from a component template such as Web Component or Angular Component templates. 👌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, still compatible with old code. It looks very well.
Thanks for the PR. Can you re-sync with the latest changes. Happy to do the review and merge. |
Hello @mebjas |
if (this.lastMatchFound === decodedText) { | ||
return; | ||
} | ||
if (qrCodeSuccessCallback) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these changes driven by some tool or manual?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param config Extra configurations to tune the code scanner. | ||
* @param verbose - If true, all logs would be printed to console. | ||
*/ | ||
public constructor( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my information, what does this constructor overload with no implementation do in typescript?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea was to have multiple constructors with a different signature each.
So in order to implement this constructor overloads, we couldn't have two constructors with bodies. You have to create the constructors signatures and then a global constructor that will handle the whole logic.
An example can be found here: https://timmousk.com/blog/typescript-multiple-constructors/
The purpose of adding multiple constructors is having the following IntelliSense suggestions:
I can remove this overloading and use one constructor instead if you prefer with the suggested signature:
public constructor(elementOrElementId: HTMLElement | string, config: Html5QrcodeScannerConfig | undefined, verbose: boolean | undefined)
Waiting for your response
Hello @mebjas |
What issue are you seeing? |
After running the
Which isn't the complete compiled library. |
Hello @mebjas ! Any updates about this PR? And please note that the compilation problem is not related to this PR. |
...we are eagerly waiting for this to work, too. (The following example isn't working yet (?): https://github.com/mebjas/html5-qrcode/tree/master/examples/lit) |
I fixed that problem by installing webpack first. npm install --save-dev webpack I also had to change lib version from es7 to es2018 in tsconfig.json |
Which problem do you mean (the custom element example does not involve any build process at all)? (Still getting "Uncaught (in promise) HTML Element with id=[object HTMLDivElement] not found"...) |
Bilal commented about not being able to build and got mostly empty .min.js file. This is to fix that problem. If you want that system, you should use Bilal's repository at his feature branch and compile it yourself to get the min.js, the one in repo is from the original one. I managed to get it working. |
Hello @cemkalyoncu Can you tell me the steps you took to make it build properly? Thanks |
Hello @mebjas I just merged the latest version of |
After last merge, the error about TS version error has disappeared. Here are the steps I have taken to build:
The minified file is built into dist folder. |
Is this PR ready to be merged? |
Hello @TheodoreGC , I updated the branch on the 29th of June and we're waiting for @mebjas to review it. Meanwhile, if you would like to use or test it, my project uses a custom branch on my forked repo. |
wouldn't be more logic and easy that @mebjas delegate his repo to trusty guys like you since there are here more than 3.7k users/developers following it? |
Any suggestions? |
for example give the rights to the most active PR guys here? |
Thank you @bilal-elchami for the update and the efforts you have put into this. Giving rights to the most active PR contributors sounds more practical for speeding up reviews and the merging process. @mebjas, do you have any idea if/when this could be implemented? |
Thank you @bilal-elchami ! @mebjas, it really raises the inclusion at the end? Best regards |
This PR is made to support sending the HTML Element of the
reader
directly to the library instead of theelement-id
string to avoid problems when using shadowRoot.An example was submitted (
examples/html5-shadow-dom
)The issue details can be found here #59
Please note that sending the
element-id
as a string is still compatible in this version.@all-contributors please add @bilal-elchami for this feature.