-
-
Notifications
You must be signed in to change notification settings - Fork 470
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
feat: support passing a {Function}
(options.insertInto
)
#279
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,13 @@ describe("basic tests", function() { | |
"<iframe class='iframeTarget'/>", | ||
"</body>", | ||
"</html>" | ||
].join("\n"), | ||
requiredJS = [ | ||
"var el = document.createElement('div');", | ||
"el.id = \"test-shadow\";", | ||
// "var shadow = el.attachShadow({ mode: 'open' })", // sadly shadow dom not working in jsdom | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I really want to test with shadow root at first, but jsdom not working with shadow dom. Maybe some day we can use smth like headless-chrome for testing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
"document.body.appendChild(el)", | ||
"var css = require('./style.css');", | ||
].join("\n"); | ||
|
||
var styleLoaderOptions = {}; | ||
|
@@ -66,7 +73,7 @@ describe("basic tests", function() { | |
|
||
// Create a tiny file system. rootDir is used because loaders are referring to absolute paths. | ||
fs.mkdirpSync(rootDir); | ||
fs.writeFileSync(rootDir + "main.js", "var css = require('./style.css');"); | ||
fs.writeFileSync(rootDir + "main.js", requiredJS); | ||
fs.writeFileSync(rootDir + "style.css", requiredCss); | ||
fs.writeFileSync(rootDir + "styleTwo.css", requiredCssTwo); | ||
fs.writeFileSync(rootDir + "localScoped.css", localScopedCss); | ||
|
@@ -140,6 +147,17 @@ describe("basic tests", function() { | |
}, selector); | ||
}); // it insert into | ||
|
||
it("insert into custom element by function", function(done) { | ||
const selector = "#test-shadow"; | ||
styleLoaderOptions.insertInto = () => document.querySelector("#test-shadow"); | ||
|
||
let expected = requiredStyle; | ||
|
||
runCompilerTest(expected, done, function() { | ||
return this.document.querySelector(selector).innerHTML; | ||
}, selector); | ||
}); | ||
|
||
it("singleton (true)", function(done) { | ||
// Setup | ||
styleLoaderOptions.singleton = true; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = function() { | ||
return document.querySelector("#test-shadow"); | ||
}; |
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.
Looks like we need new keyword in ajv for this
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.
Yep, a newer version of
schema-utils
is needed