-
Notifications
You must be signed in to change notification settings - Fork 69
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
when I use '&' before Css selector,but the string is still black #61
Comments
Hey @phoebepei, looks like you are correct I've gotten both var obj = $$({}, '<p><div>Do this</div></p>', '& { color:red; }'); and var obj = $$({}, '<p><div>Do this</div></p>', 'div { color:red; }'); to show red, but not var obj = $$({}, '<p><div>Do this</div></p>', '& div { color:red; }'); the last example ( which is what isn't working, same as you provided ) generates the following html <head>
<style type="text/css">.agility_1 div { color:red; }</style>
</head>
<body>
<p class="agility_1"></p>
<div class="agility_1">Do this</div>
<p class="agility_1"></p>
</body> @arturadib , looks like the wrong structure is generated ( notice each |
@tristanls , here is another exmaple in the document <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Agility complex-need-& </title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="agility.js" charset="utf-8"></script>
</head>
<body>
<script type="text/javascript" charset="utf-8">
var obj = $$({
view:{
format: '<div>\
<div id="hello">Hello</div>\
<div id="world">World</div>\
</div>',
style: '& {border:5px solid green; color:white;}\
& div {padding: 10px 20px;}\
& #hello { background: blue; }\
& #world { background: red; }'
}
});
$$.document.append(obj);
</script>
</body>
</html> it works well...... <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Agility style-need-& </title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="agility.js" charset="utf-8"></script>
</head>
<body>
<script type="text/javascript" charset="utf-8">
var obj = $$({}, '<div><p>Do this</p></div>', '& p { color:red; }');
$$.document.append(obj);
</script>
</body>
</html> it works! |
That's a DOM limitation (not Agility's) and I completely missed that in the Docs! (You can't insert block elements inside a paragraph, so the browser falls back to the structure you quoted, see http://www.w3.org/TR/html401/struct/text.html#h-9.3.1). I've fixed the docs, thanks @phoebepei and @tristanls ! |
I just copy the code these code from doc,but it doesn't work! does I do something wrong?
The text was updated successfully, but these errors were encountered: