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 schema attributes to Html2React #854

Open
codemonkeynorth opened this issue Jun 25, 2021 · 8 comments
Open

Add schema attributes to Html2React #854

codemonkeynorth opened this issue Jun 25, 2021 · 8 comments
Labels
good first issue Good for newcomers

Comments

@codemonkeynorth
Copy link

codemonkeynorth commented Jun 25, 2021

Expected behavior

itemProp, itemScope and itemType should be created on elements

Observed behavior

javascript error for itemprop, itemscope and itemtype on html elements

Steps involved to reproduce the problem

add eg <span itemprop="telephone">999</span> to some HTML content in the database and run Html2React on it

Possible solution

add the following attributes to https://github.com/frontity/frontity/blob/dev/packages/html2react/src/libraries/parse/attributes/html.json

  "itemProp",
  "itemScope",
  "itemType",
@codemonkeynorth
Copy link
Author

codemonkeynorth commented Jun 28, 2021

was going to add a Pull Request but the contribution docs seem out of date? https://docs.frontity.org/contributing/code-contribution-guide

Specifically, there is no examples folder after running npm install

@cristianbote
Copy link
Member

was going to add a Pull Request but the contribution docs seem out of date? https://docs.frontity.org/contributing/code-contribution-guide

Specifically, there is no examples folder after running npm install

That's a good catch @codemonkeynorth! examples have been renamed to projects 👍

@DAreRodz
Copy link
Member

Hey @codemonkeynorth, if you create a PR, could you add itemID and itemRef as well? That way we would be fixing all the item-related attributes defined in the HTML spec. 😊

@luisherranz luisherranz added the good first issue Good for newcomers label Jun 30, 2021
@luisherranz luisherranz changed the title add schema attributes to Html2React Add schema attributes to Html2React Jun 30, 2021
@codemonkeynorth
Copy link
Author

@DAreRodz noted.

Still having trouble with e2e on windows

theoretically I’m only adding some strings and therefore there’s no real need to test everything?

(that part passed anyway, I’m just having trouble with Cypress now)

I know they’re going to pass at the Frontity team end so I may just try commit anyway

@DAreRodz
Copy link
Member

DAreRodz commented Jul 1, 2021

@codemonkeynorth, don't worry about e2e testing, you can add some simple checks in this unit test:

test("maps from HTML attributes to react props", () => {
const result = parse(
'<div class="test-class"> test </div> <label for="nothing"></label>'
) as Element[];
expect((result[0].props as any).class).toBeUndefined();
expect(result[0].props.className).toBe("test-class");
expect((result[1].props as any).for).toBeUndefined();
expect(result[1].props.htmlFor).toBe("nothing");
});

About running e2e tests on Windows, could you please share the error you got? I have Windows so I can take a look into that.

@codemonkeynorth
Copy link
Author

@DAreRodz well the first is Docker is not running. Please start it or use --wp off.

so if i add that last flag I'm getting

Error: Cannot find module '@frontity/core'
Make sure that you are running frontity inside a Frontity project.

I'm just following the instructions here
https://docs.frontity.org/contributing/code-contribution-guide

@codemonkeynorth
Copy link
Author

note we should also maybe add these non-standard items
https://react-cn.github.io/react/docs/tags-and-attributes.html#html-attributes

"autoCapitalize",
"autoCorrect",
"autoSave"

@luisherranz
Copy link
Member

luisherranz commented Jul 5, 2021

so if i add that last flag I'm getting
Error: Cannot find module '@frontity/core'

Did you run npm install in the root folder?


@juanmaguitar: Maybe this is a good opportunity to improve our contribution guides 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants