Skip to content

Update detector.js #240

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

Merged
merged 5 commits into from
Feb 14, 2017
Merged

Update detector.js #240

merged 5 commits into from
Feb 14, 2017

Conversation

shershen08
Copy link
Contributor

added findVueRootNode method to avoid prototype.js error
#171

added findVueRootNode method to avoid prototype.js error vuejs#171
@@ -5,9 +5,15 @@ window.addEventListener('message', e => {
})

function detect (win) {
function findVueRootNode (array, callback) {
for (let i = 0; i < array.length;i++) {
console.log(array[i])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it should not be here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, totally, it's from my local test setup O_o

removed the 'console.log' line
@shershen08
Copy link
Contributor Author

is there any more action needed for this change?

@posva
Copy link
Member

posva commented Jan 30, 2017

Sorry, I forgot about this. I'll test it and merge this afternoon

@@ -5,9 +5,14 @@ window.addEventListener('message', e => {
})

function detect (win) {
function findVueRootNode (array, callback) {
for (let i = 0; i < array.length;i++) {
if (Function.prototype.call(array[i], callback)) return array[i]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why Function.prototype.call here?

@@ -5,9 +5,14 @@ window.addEventListener('message', e => {
})

function detect (win) {
function findVueRootNode (array, callback) {
for (let i = 0; i < array.length;i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space after second semicolon please :P

fix linting
use .call directly rather than prototype
@shershen08
Copy link
Contributor Author

fixed requested changes

@@ -5,9 +5,14 @@ window.addEventListener('message', e => {
})

function detect (win) {
function findVueRootNode (array, callback) {
for (let i = 0; i < array.length; i++) {
if (callback.call(array[i])) return array[i]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for the .call here either, just callback(array[i]) would do.

BTW The first argument to fn.call() is the this context it will be called with.

@yyx990803 yyx990803 merged commit 93f202d into vuejs:master Feb 14, 2017
@yyx990803 yyx990803 mentioned this pull request Feb 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants