public JsonValue(String value) { _value = value.CssString(); }
/// <summary> /// Creates a new attribute matches hyphen separated list selector. /// </summary> /// <param name="match">The attribute that has to be available.</param> /// <param name="value">The value (hyphen separated list).</param> /// <param name="prefix">The optional namespace prefix to use.</param> /// <returns>The new selector.</returns> public static SimpleSelector AttrHyphen(String match, String value, String prefix = null) { var front = match; if (!String.IsNullOrEmpty(prefix)) { front = String.Concat(prefix, "|", match); if (prefix != "*") match = String.Concat(prefix, ":", match); } var code = String.Format("[{0}|={1}]", front, value.CssString()); if (String.IsNullOrEmpty(value)) return new SimpleSelector(_ => false, Priority.OneClass, code); return new SimpleSelector(_ => (_.GetAttribute(match) ?? String.Empty).HasHyphen(value), Priority.OneClass, code); }
/// <summary> /// Creates a new attribute not-match selector. /// </summary> /// <param name="match">The attribute that has to be available.</param> /// <param name="value">The value to not match.</param> /// <param name="prefix">The optional namespace prefix to use.</param> /// <returns>The new selector.</returns> public static SimpleSelector AttrNotMatch(String match, String value, String prefix = null) { var front = match; if (!String.IsNullOrEmpty(prefix)) { front = String.Concat(prefix, "|", match); if (prefix != "*") match = String.Concat(prefix, ":", match); } var code = String.Format("[{0}!={1}]", front, value.CssString()); return new SimpleSelector(_ => _.GetAttribute(match) != value, Priority.OneClass, code); }
public static SimpleSelector AttrContains(String match, String value, String prefix = null) { var front = match; if (!String.IsNullOrEmpty(prefix)) { front = String.Concat(prefix, "|", match); match = Bundle(prefix, match); } var code = String.Format("[{0}*={1}]", front, value.CssString()); var matches = Select(value, _ => (_.GetAttribute(match) ?? String.Empty).Contains(value)); return new SimpleSelector(matches, Priority.OneClass, code); }
public static SimpleSelector AttrMatch(String match, String value, String prefix = null) { var front = match; if (!String.IsNullOrEmpty(prefix)) { front = FormFront(prefix, match); match = FormMatch(prefix, match); } var code = FormCode(front, "=", value.CssString()); return new SimpleSelector(_ => _.GetAttribute(match).Is(value), Priority.OneClass, code); }
public static SimpleSelector AttrHyphen(String match, String value, String prefix = null) { var front = match; if (!String.IsNullOrEmpty(prefix)) { front = FormFront(prefix, match); match = FormMatch(prefix, match); } var code = FormCode(front, "|=", value.CssString()); var matches = Select(value, _ => (_.GetAttribute(match) ?? String.Empty).HasHyphen(value)); return new SimpleSelector(matches, Priority.OneClass, code); }