Skip to content
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

Add support for multi windows. #278

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Add support for multi windows. #278

wants to merge 10 commits into from

Conversation

vipcxj
Copy link

@vipcxj vipcxj commented May 8, 2017

Add props: window and document. With them, this library will work with multi windows environment.
For example, with https://github.com/ryanseddon/react-frame-component:

<Frame>
<Helmet window={this.context.window} document={this.context.document}>
<Script>...</Script>
</Helmet>
</Frame>
The script will be add to the head of the iframe instead of the parent window.

update: add a feature.
<Helmet>
<body sytle={{color: 'red'}}/>
</Helmet>
this works now.

@CLAassistant
Copy link

CLAassistant commented May 8, 2017

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link

codecov bot commented May 8, 2017

Codecov Report

Merging #278 into master will decrease coverage by 1.29%.
The diff coverage is 92.55%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #278     +/-   ##
=========================================
- Coverage   98.92%   97.62%   -1.3%     
=========================================
  Files           3        3             
  Lines         278      337     +59     
=========================================
+ Hits          275      329     +54     
- Misses          3        8      +5
Impacted Files Coverage Δ
src/Helmet.js 100% <ø> (ø) ⬆️
src/HelmetUtils.js 97.03% <92.55%> (-1.55%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aad5457...22cc083. Read the comment docs.

vipcxj added 2 commits May 8, 2017 19:47
<body style={{color: "red"}}/>
add unit test.
Copy link
Contributor

@jamsea jamsea left a comment

Choose a reason for hiding this comment

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

Thanks for taking the time to make a PR @vipcxj! We need a bit more time to look at this (there's quite a few changes) but I left a few comments in the mean time.

Also it looks like you have some merge conflicts with master, can you merge master into your branch and update the PR?

@@ -78,6 +79,7 @@
"phantomjs-prebuilt": "^2.1.14",
"react": "^15.x",
"react-dom": "^15.x",
"react-frame-component": "^1.0.3",
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like this is only being used in tests, can you move this to devDependencies?

Copy link
Author

Choose a reason for hiding this comment

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

it has been the devDependency.

package.json Outdated
@@ -31,6 +31,7 @@
},
"dependencies": {
"deep-equal": "^1.0.1",
"lodash": "^4.17.4",
Copy link
Contributor

Choose a reason for hiding this comment

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

We want to avoid taking lodash as a dependency. It looks like you can use ES6 functions like Array.isArray in the places you're using lodash. Is there an alternative _.groupBy and _.kebabCase you could use? If not can you add lodash.groupby and lodash.kebabcase as a dependency instead of the full lodash package?

@@ -809,6 +811,32 @@ describe("Helmet - Declarative API", () => {
});
});

it("use style object in body.", (done) => {
/* eslint-disable */
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to disable every eslint rule for this block? Worst case scenario could you specify which rules need to be disabled? (similar to line 3 in this file)

@vipcxj
Copy link
Author

vipcxj commented May 13, 2017

I have merge master, no conflicts now. And I replace full version lodash with module version lodash. All test passed.

@richtr
Copy link

richtr commented Sep 21, 2017

Any chance we could get an update on this PR @vipcxj @jamsea?

@smddzcy
Copy link

smddzcy commented Nov 13, 2017

Any updates on this one? We are currently having problems because Helmet doesn't support multiple windows.

@vipcxj
Copy link
Author

vipcxj commented Nov 14, 2017

@smddzcy I can resolve conflicts when I am not busy. But I don't know how to pass codecov check.

@smddzcy
Copy link

smddzcy commented Nov 14, 2017

@vipcxj You can see the untested lines of code here: https://codecov.io/gh/nfl/react-helmet/pull/278/diff

@miaklwalker
Copy link

miaklwalker commented Apr 7, 2020

Wouldn't a kebob-case function be as simple as looking at charCodes for any character falling in the range 65 - 90 and replace it with "-" and that same charCode plus 32 ?

`/**
*

  • @param camelCaseString - A camelCased String that needs to be converted to kabob-case

  • @description As camelCase never begins with a capital this function naively assumes camelCaseString will not either

  • @returns {string} - A String formatted in kabob-case
    */
    function camelToKabobConverter(camelCaseString){
    let result = '';
    for(let i = 0 ; i < camelCaseString.length ; i++){
    let charCode = camelCaseString.charCodeAt(i);
    result += (charCode <= 90 && charCode >= 65) ?
    -${String.fromCharCode(charCode+32)}
    : String.fromCharCode(charCode);

    }
    return result
    }
    console.log(camelToKabobConverter('helloWorld')); // hello-world`

SimeonC added a commit to SimeonC/react-helmet-async that referenced this pull request Nov 10, 2020
For related react-helmet issue see nfl/react-helmet#278.

Mostly this will be used to inject scripts/styles into the iframe.
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.

6 participants