-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for :default, and rename group input to form
- Loading branch information
Showing
13 changed files
with
165 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"use strict"; | ||
|
||
const walk = require("posthtml/lib/api").walk, | ||
get = require("lodash/get"), | ||
|
||
addClassNameToNode = require("../addClassNameToNode"), | ||
|
||
eligibleTags = [ | ||
"button", | ||
"input" | ||
], | ||
className = ":default"; | ||
|
||
module.exports = function(node) { | ||
let test = false; | ||
|
||
if(!node.tag || node.tag !== "form" || !node.content.length) { | ||
return node; | ||
} | ||
|
||
walk.call(node, (subNode) => { | ||
if(test || !subNode.tag || eligibleTags.indexOf(subNode.tag) === -1 || | ||
(subNode.tag === "input" && get(subNode, [ "attrs", "type"]) !== "submit")) { | ||
return subNode; | ||
} | ||
|
||
test = true; | ||
addClassNameToNode(subNode, className); | ||
|
||
return subNode; | ||
}); | ||
|
||
return node; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>page title</title> | ||
</head> | ||
<body> | ||
<h1>header</h1> | ||
<form action="#"> | ||
<input type="text" placeholder="Name" disabled=""> | ||
<input type="text" placeholder="Address" readonly=""> | ||
<input class="zipcode" type="text" placeholder="Zip Code"> | ||
|
||
<input class="submit :default" type="submit" name="" value="submit" readonly="readonly"> | ||
|
||
<select readonly=""> | ||
<option>option 1</option> | ||
<option>option 2</option> | ||
<option>option 3</option> | ||
</select> | ||
|
||
<textarea></textarea> | ||
|
||
<button type="button">Button</button> | ||
</form> | ||
|
||
<form> | ||
<input type="text" name=""> | ||
<div> | ||
<button class=":default">Click</button> | ||
</div> | ||
<button>Click 2</button> | ||
</form> | ||
|
||
<div> | ||
outer | ||
<div>Inner</div> | ||
</div> | ||
|
||
<form> | ||
<input type="text"> | ||
<input type="text" disabled=""> | ||
<div> | ||
<button disabled="" class=":default">click</button> | ||
<input type="submit" value="submit"> | ||
</div> | ||
</form> | ||
|
||
<button>button</button> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>page title</title> | ||
</head> | ||
<body> | ||
<h1>header</h1> | ||
<form action="#"> | ||
<input type="text" placeholder="Name" disabled> | ||
<input type="text" placeholder="Address" readonly> | ||
<input class="zipcode" type="text" placeholder="Zip Code"> | ||
|
||
<input class="submit" type="submit" name="" value="submit" readonly="readonly"> | ||
|
||
<select readonly> | ||
<option>option 1</option> | ||
<option>option 2</option> | ||
<option>option 3</option> | ||
</select> | ||
|
||
<textarea></textarea> | ||
|
||
<button type="button">Button</button> | ||
</form> | ||
|
||
<form> | ||
<input type="text" name=""> | ||
<div> | ||
<button>Click</button> | ||
</div> | ||
<button>Click 2</button> | ||
</form> | ||
|
||
<div> | ||
outer | ||
<div>Inner</div> | ||
</div> | ||
|
||
<form> | ||
<input type="text"> | ||
<input type="text" disabled> | ||
<div> | ||
<button disabled="">click</button> | ||
<input type="submit" value="submit"> | ||
</div> | ||
</form> | ||
|
||
<button>button</button> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters